fix: allow vars with formula-on-bead slings (#966)
This commit is contained in:
@@ -131,11 +131,6 @@ func runSling(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
townBeadsDir := filepath.Join(townRoot, ".beads")
|
||||
|
||||
// --var is only for standalone formula mode, not formula-on-bead mode
|
||||
if slingOnTarget != "" && len(slingVars) > 0 {
|
||||
return fmt.Errorf("--var cannot be used with --on (formula-on-bead mode doesn't support variables)")
|
||||
}
|
||||
|
||||
// Batch mode detection: multiple beads with rig target
|
||||
// Pattern: gt sling gt-abc gt-def gt-ghi gastown
|
||||
// When len(args) > 2 and last arg is a rig, sling each bead to its own polecat
|
||||
@@ -434,7 +429,7 @@ func runSling(cmd *cobra.Command, args []string) error {
|
||||
if formulaName != "" {
|
||||
fmt.Printf(" Instantiating formula %s...\n", formulaName)
|
||||
|
||||
result, err := InstantiateFormulaOnBead(formulaName, beadID, info.Title, hookWorkDir, townRoot, false)
|
||||
result, err := InstantiateFormulaOnBead(formulaName, beadID, info.Title, hookWorkDir, townRoot, false, slingVars)
|
||||
if err != nil {
|
||||
return fmt.Errorf("instantiating formula %s: %w", formulaName, err)
|
||||
}
|
||||
|
||||
@@ -120,7 +120,8 @@ exit /b 0
|
||||
}
|
||||
|
||||
// Test the helper function directly
|
||||
result, err := InstantiateFormulaOnBead("mol-polecat-work", "gt-abc123", "Test Bug Fix", "", townRoot, false)
|
||||
extraVars := []string{"branch=polecat/furiosa/gt-abc123"}
|
||||
result, err := InstantiateFormulaOnBead("mol-polecat-work", "gt-abc123", "Test Bug Fix", "", townRoot, false, extraVars)
|
||||
if err != nil {
|
||||
t.Fatalf("InstantiateFormulaOnBead failed: %v", err)
|
||||
}
|
||||
@@ -145,6 +146,9 @@ exit /b 0
|
||||
if !strings.Contains(logContent, "mol wisp mol-polecat-work") {
|
||||
t.Errorf("mol wisp command not found in log:\n%s", logContent)
|
||||
}
|
||||
if !strings.Contains(logContent, "--var branch=polecat/furiosa/gt-abc123") {
|
||||
t.Errorf("extra vars not passed to wisp command:\n%s", logContent)
|
||||
}
|
||||
if !strings.Contains(logContent, "mol bond") {
|
||||
t.Errorf("mol bond command not found in log:\n%s", logContent)
|
||||
}
|
||||
@@ -219,7 +223,7 @@ exit /b 0
|
||||
_ = os.Chdir(townRoot)
|
||||
|
||||
// Test with skipCook=true
|
||||
_, err := InstantiateFormulaOnBead("mol-polecat-work", "gt-test", "Test", "", townRoot, true)
|
||||
_, err := InstantiateFormulaOnBead("mol-polecat-work", "gt-test", "Test", "", townRoot, true, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("InstantiateFormulaOnBead failed: %v", err)
|
||||
}
|
||||
@@ -416,7 +420,7 @@ exit /b 0
|
||||
t.Cleanup(func() { _ = os.Chdir(cwd) })
|
||||
_ = os.Chdir(townRoot)
|
||||
|
||||
_, err := InstantiateFormulaOnBead("mol-polecat-work", "gt-abc123", "My Cool Feature", "", townRoot, false)
|
||||
_, err := InstantiateFormulaOnBead("mol-polecat-work", "gt-abc123", "My Cool Feature", "", townRoot, false, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("InstantiateFormulaOnBead: %v", err)
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ func runBatchSling(beadIDs []string, rigName string, townBeadsDir string) error
|
||||
beadToHook := beadID
|
||||
attachedMoleculeID := ""
|
||||
if formulaCooked {
|
||||
result, err := InstantiateFormulaOnBead(formulaName, beadID, info.Title, hookWorkDir, townRoot, true)
|
||||
result, err := InstantiateFormulaOnBead(formulaName, beadID, info.Title, hookWorkDir, townRoot, true, slingVars)
|
||||
if err != nil {
|
||||
fmt.Printf(" %s Could not apply formula: %v (hooking raw bead)\n", style.Dim.Render("Warning:"), err)
|
||||
} else {
|
||||
|
||||
@@ -475,9 +475,10 @@ type FormulaOnBeadResult struct {
|
||||
// - hookWorkDir: working directory for bd commands (polecat's worktree)
|
||||
// - townRoot: the town root directory
|
||||
// - skipCook: if true, skip cooking (for batch mode optimization where cook happens once)
|
||||
// - extraVars: additional --var values supplied by the user
|
||||
//
|
||||
// Returns the wisp root ID which should be hooked.
|
||||
func InstantiateFormulaOnBead(formulaName, beadID, title, hookWorkDir, townRoot string, skipCook bool) (*FormulaOnBeadResult, error) {
|
||||
func InstantiateFormulaOnBead(formulaName, beadID, title, hookWorkDir, townRoot string, skipCook bool, extraVars []string) (*FormulaOnBeadResult, error) {
|
||||
// Route bd mutations (wisp/bond) to the correct beads context for the target bead.
|
||||
formulaWorkDir := beads.ResolveHookDir(townRoot, beadID, hookWorkDir)
|
||||
|
||||
@@ -494,7 +495,11 @@ func InstantiateFormulaOnBead(formulaName, beadID, title, hookWorkDir, townRoot
|
||||
// Step 2: Create wisp with feature and issue variables from bead
|
||||
featureVar := fmt.Sprintf("feature=%s", title)
|
||||
issueVar := fmt.Sprintf("issue=%s", beadID)
|
||||
wispArgs := []string{"--no-daemon", "mol", "wisp", formulaName, "--var", featureVar, "--var", issueVar, "--json"}
|
||||
wispArgs := []string{"--no-daemon", "mol", "wisp", formulaName, "--var", featureVar, "--var", issueVar}
|
||||
for _, variable := range extraVars {
|
||||
wispArgs = append(wispArgs, "--var", variable)
|
||||
}
|
||||
wispArgs = append(wispArgs, "--json")
|
||||
wispCmd := exec.Command("bd", wispArgs...)
|
||||
wispCmd.Dir = formulaWorkDir
|
||||
wispCmd.Env = append(os.Environ(), "GT_ROOT="+townRoot)
|
||||
|
||||
@@ -66,6 +66,7 @@ func EnsureGitignorePatterns(worktreePath string) error {
|
||||
".runtime/",
|
||||
".claude/",
|
||||
".logs/",
|
||||
".beads/",
|
||||
}
|
||||
|
||||
// Read existing gitignore content
|
||||
|
||||
Reference in New Issue
Block a user