feat: add config package with types and JSON serialization

Types:
- TownConfig: main town configuration (config/town.json)
- RigsConfig: rigs registry with BeadsConfig per rig
- AgentState: agent state with role, session, extras

Features:
- Load/Save functions for all types
- Version compatibility checks
- Required field validation
- Creates parent directories on save

Closes gt-f9x.1

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-16 13:24:28 -08:00
parent a4677191d1
commit e16931b304
3 changed files with 365 additions and 0 deletions

45
internal/config/types.go Normal file
View File

@@ -0,0 +1,45 @@
// Package config provides configuration types and serialization for Gas Town.
package config
import "time"
// TownConfig represents the main town configuration (config/town.json).
type TownConfig struct {
Type string `json:"type"` // "town"
Version int `json:"version"` // schema version
Name string `json:"name"` // town identifier
CreatedAt time.Time `json:"created_at"`
}
// RigsConfig represents the rigs registry (config/rigs.json).
type RigsConfig struct {
Version int `json:"version"`
Rigs map[string]RigEntry `json:"rigs"`
}
// RigEntry represents a single rig in the registry.
type RigEntry struct {
GitURL string `json:"git_url"`
AddedAt time.Time `json:"added_at"`
BeadsConfig *BeadsConfig `json:"beads,omitempty"`
}
// BeadsConfig represents beads configuration for a rig.
type BeadsConfig struct {
Repo string `json:"repo"` // "local" | path | git-url
Prefix string `json:"prefix"` // issue prefix
}
// AgentState represents an agent's current state (*/state.json).
type AgentState struct {
Role string `json:"role"` // "mayor", "witness", etc.
LastActive time.Time `json:"last_active"`
Session string `json:"session,omitempty"`
Extra map[string]any `json:"extra,omitempty"`
}
// CurrentTownVersion is the current schema version for TownConfig.
const CurrentTownVersion = 1
// CurrentRigsVersion is the current schema version for RigsConfig.
const CurrentRigsVersion = 1