feat(rig): add rig identity bead schema and creation (gt-zmznh)

- Add RigFields struct, CreateRigBead, RigBeadID helpers to beads package
- Modify gt rig add to create rig identity bead after rig creation
- Schema: id=<prefix>-rig-<name>, type=rig, with repo/prefix/state fields

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
furiosa
2026-01-06 18:54:55 -08:00
committed by Steve Yegge
parent 1f44482ad0
commit ec53dfbb40
2 changed files with 131 additions and 0 deletions

View File

@@ -366,12 +366,16 @@ func runRigAdd(cmd *cobra.Command, args []string) error {
// - Otherwise route to rig root (where initBeads creates the database)
// The conditional routing is necessary because initBeads creates the database at
// "<rig>/.beads", while repos with tracked beads have their database at mayor/rig/.beads.
var beadsWorkDir string
if newRig.Config.Prefix != "" {
routePath := name
mayorRigBeads := filepath.Join(townRoot, name, "mayor", "rig", ".beads")
if _, err := os.Stat(mayorRigBeads); err == nil {
// Source repo has .beads/ tracked - route to mayor/rig
routePath = name + "/mayor/rig"
beadsWorkDir = filepath.Join(townRoot, name, "mayor", "rig")
} else {
beadsWorkDir = filepath.Join(townRoot, name)
}
route := beads.Route{
Prefix: newRig.Config.Prefix + "-",
@@ -383,6 +387,23 @@ func runRigAdd(cmd *cobra.Command, args []string) error {
}
}
// Create rig identity bead
if newRig.Config.Prefix != "" && beadsWorkDir != "" {
bd := beads.New(beadsWorkDir)
rigBeadID := beads.RigBeadIDWithPrefix(newRig.Config.Prefix, name)
fields := &beads.RigFields{
Repo: gitURL,
Prefix: newRig.Config.Prefix,
State: "active",
}
if _, err := bd.CreateRigBead(rigBeadID, name, fields); err != nil {
// Non-fatal: rig is functional without the identity bead
fmt.Printf(" %s Could not create rig identity bead: %v\n", style.Warning.Render("!"), err)
} else {
fmt.Printf(" Created rig identity bead: %s\n", rigBeadID)
}
}
elapsed := time.Since(startTime)
// Read default branch from rig config