Skip to content

config

import "github.com/ananth/codespace-zed/internal/config"

Package config loads the codespace-zed JSONC configuration file and defines the Target struct that describes a named codespace target (repository, branch, machine type, Zed display settings, etc.).

Index

Variables

DaemonFieldDocs is the authoritative documentation for DaemonConfig fields.

var DaemonFieldDocs = []FieldDoc{
    {"hotkey", "string", false, "Global hotkey (e.g. Cmd+Shift+S)"},
    {"hotkeyAction", "string", false, "Hotkey behavior: picker (default), previous, or default"},
    {"terminal", "string", false, "Terminal app for picker; auto to detect"},
    {"pollInterval", "string", false, "Codespace poll interval (e.g. 5m)"},
}

TargetFieldDocs is the authoritative documentation for every Target field.

var TargetFieldDocs = []FieldDoc{
    {"repository", "string", true, "GitHub repository in owner/repo form"},
    {"branch", "string", false, "Preferred branch when creating or matching a codespace"},
    {"displayName", "string", false, "Exact display name to disambiguate codespace matches"},
    {"codespaceName", "string", false, "Exact codespace name for strict reuse"},
    {"workspacePath", "string", true, "Remote folder Zed should open (e.g. /workspaces/repo)"},
    {"machine", "string", false, "Machine type forwarded to gh codespace create"},
    {"location", "string", false, "Location forwarded to gh codespace create"},
    {"devcontainerPath", "string", false, "Dev container config path forwarded to gh codespace create"},
    {"idleTimeout", "string", false, "Idle timeout forwarded to gh codespace create (e.g. 30m)"},
    {"retentionPeriod", "string", false, "Retention period forwarded to gh codespace create (e.g. 720h)"},
    {"uploadBinaryOverSsh", "bool", false, "Set Zed's upload_binary_over_ssh for this host"},
    {"zedNickname", "string", false, "Friendly name shown in Zed's remote project list"},
    {"autoStop", "string", false, "Auto-stop codespace after idle duration (e.g. 30m)"},
    {"preWarm", "string", false, "Time-of-day to pre-warm codespace (e.g. 08:00)"},
}

func DaemonFieldsHelp

func DaemonFieldsHelp() string

DaemonFieldsHelp returns a formatted help string for daemon config fields.

func ParseJSONC

func ParseJSONC(source string) ([]byte, error)

ParseJSONC strips comments and trailing commas, then returns clean JSON bytes.

func ParseJSONCAny

func ParseJSONCAny(source string) (any, error)

ParseJSONCAny parses JSONC into an arbitrary value (used for Zed settings).

func TargetFieldsHelp

func TargetFieldsHelp() string

TargetFieldsHelp returns a formatted help string for all target fields.

type Config

type Config struct {
    DefaultTarget string            `json:"defaultTarget,omitempty"`
    Targets       map[string]Target `json:"targets"`
    Daemon        *DaemonConfig     `json:"daemon,omitempty"`
}

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig reads a JSONC config file and returns the parsed Config.

type DaemonConfig

DaemonConfig holds settings for the background daemon (tray, hotkey, poller).

type DaemonConfig struct {
    Hotkey       string `json:"hotkey,omitempty"`       // e.g. "Cmd+Shift+S" (macOS) or "Ctrl+Shift+S" (Linux)
    HotkeyAction string `json:"hotkeyAction,omitempty"` // "picker" (default), "previous", or "default"
    Terminal     string `json:"terminal,omitempty"`     // terminal app to launch picker in; "auto" to detect
    PollInterval string `json:"pollInterval,omitempty"` // how often to poll codespace state (e.g. "5m")
}

type FieldDoc

FieldDoc describes a single config target field for generated documentation.

type FieldDoc struct {
    JSON     string // JSON key name
    Type     string // human-readable type
    Required bool
    Desc     string
}

type Target

type Target struct {
    Repository          string `json:"repository"`
    Branch              string `json:"branch,omitempty"`
    DisplayName         string `json:"displayName,omitempty"`
    CodespaceName       string `json:"codespaceName,omitempty"`
    WorkspacePath       string `json:"workspacePath"`
    Machine             string `json:"machine,omitempty"`
    Location            string `json:"location,omitempty"`
    DevcontainerPath    string `json:"devcontainerPath,omitempty"`
    IdleTimeout         string `json:"idleTimeout,omitempty"`
    RetentionPeriod     string `json:"retentionPeriod,omitempty"`
    UploadBinaryOverSSH *bool  `json:"uploadBinaryOverSsh,omitempty"`
    ZedNickname         string `json:"zedNickname,omitempty"`
    AutoStop            string `json:"autoStop,omitempty"` // auto-stop after idle duration (e.g. "30m")
    PreWarm             string `json:"preWarm,omitempty"`  // time-of-day to pre-warm codespace (e.g. "08:00")
}

Generated by gomarkdoc