feat(config): support daemon.auto_* settings in config.yaml (GH#871)
Allow team-wide auto-sync configuration via config.yaml instead of SQLite. This enables teams to share auto-commit/auto-push settings through version control. Changes: - Add daemon.auto_commit, daemon.auto_push, daemon.auto_pull to YamlOnlyKeys - Add daemon.* prefix to YAML-only prefixes - Update daemon startup to read from config.yaml first, then fall back to SQLite - Update bd init --team to write daemon settings to config.yaml Usage: # In .beads/config.yaml (version controlled, shared by team) daemon.auto_commit: true daemon.auto_push: true # Or via bd config set bd config set daemon.auto_commit true 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/steveyegge/beads/cmd/bd/doctor"
|
||||
"github.com/steveyegge/beads/internal/beads"
|
||||
"github.com/steveyegge/beads/internal/config"
|
||||
"github.com/steveyegge/beads/internal/daemon"
|
||||
"github.com/steveyegge/beads/internal/rpc"
|
||||
"github.com/steveyegge/beads/internal/storage/sqlite"
|
||||
@@ -67,10 +68,15 @@ Run 'bd daemon' with no flags to see available options.`,
|
||||
}
|
||||
|
||||
// If auto-commit/auto-push flags weren't explicitly provided, read from config
|
||||
// GH#871: Read from config.yaml first (team-shared), then fall back to SQLite (legacy)
|
||||
// (skip if --stop, --status, --health, --metrics)
|
||||
if start && !stop && !status && !health && !metrics {
|
||||
if !cmd.Flags().Changed("auto-commit") {
|
||||
if dbPath := beads.FindDatabasePath(); dbPath != "" {
|
||||
// Check config.yaml first (GH#871: team-wide settings)
|
||||
if config.GetBool("daemon.auto_commit") {
|
||||
autoCommit = true
|
||||
} else if dbPath := beads.FindDatabasePath(); dbPath != "" {
|
||||
// Fall back to SQLite for backwards compatibility
|
||||
ctx := context.Background()
|
||||
store, err := sqlite.New(ctx, dbPath)
|
||||
if err == nil {
|
||||
@@ -82,7 +88,11 @@ Run 'bd daemon' with no flags to see available options.`,
|
||||
}
|
||||
}
|
||||
if !cmd.Flags().Changed("auto-push") {
|
||||
if dbPath := beads.FindDatabasePath(); dbPath != "" {
|
||||
// Check config.yaml first (GH#871: team-wide settings)
|
||||
if config.GetBool("daemon.auto_push") {
|
||||
autoPush = true
|
||||
} else if dbPath := beads.FindDatabasePath(); dbPath != "" {
|
||||
// Fall back to SQLite for backwards compatibility
|
||||
ctx := context.Background()
|
||||
store, err := sqlite.New(ctx, dbPath)
|
||||
if err == nil {
|
||||
@@ -97,8 +107,11 @@ Run 'bd daemon' with no flags to see available options.`,
|
||||
// Check environment variable first
|
||||
if envVal := os.Getenv("BEADS_AUTO_PULL"); envVal != "" {
|
||||
autoPull = envVal == "true" || envVal == "1"
|
||||
} else if config.GetBool("daemon.auto_pull") {
|
||||
// Check config.yaml (GH#871: team-wide settings)
|
||||
autoPull = true
|
||||
} else if dbPath := beads.FindDatabasePath(); dbPath != "" {
|
||||
// Check database config
|
||||
// Fall back to SQLite for backwards compatibility
|
||||
ctx := context.Background()
|
||||
store, err := sqlite.New(ctx, dbPath)
|
||||
if err == nil {
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/steveyegge/beads/internal/config"
|
||||
"github.com/steveyegge/beads/internal/storage"
|
||||
"github.com/steveyegge/beads/internal/ui"
|
||||
)
|
||||
@@ -117,11 +118,12 @@ func runTeamWizard(ctx context.Context, store storage.Storage) error {
|
||||
autoSync := !(response == "n" || response == "no")
|
||||
|
||||
if autoSync {
|
||||
if err := store.SetConfig(ctx, "daemon.auto_commit", "true"); err != nil {
|
||||
// GH#871: Write to config.yaml for team-wide settings (version controlled)
|
||||
if err := config.SetYamlConfig("daemon.auto_commit", "true"); err != nil {
|
||||
return fmt.Errorf("failed to enable auto-commit: %w", err)
|
||||
}
|
||||
|
||||
if err := store.SetConfig(ctx, "daemon.auto_push", "true"); err != nil {
|
||||
if err := config.SetYamlConfig("daemon.auto_push", "true"); err != nil {
|
||||
return fmt.Errorf("failed to enable auto-push: %w", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user