package cli import ( "fmt" "github.com/spf13/cobra" "github.com/m3tam3re/agent-lib/internal/client" ) func newSyncCmd() *cobra.Command { var configPath, repoURL, ref string cmd := &cobra.Command{ Use: "sync", Short: "Pull the work repository and deploy its content to OpenCode", Long: "Pulls the work repository and deploys skills, commands and agents " + "into the OpenCode runtime paths. The repository comes from --repo, " + "or from the config chain: --config, " + client.ConfigEnv + " env, the " + "user-level config, or the admin-protected platform default. " + "Idempotent: re-running changes nothing when content and disk match.", Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { opts := client.SyncOptions{ConfigPath: configPath, RepoURL: repoURL, Ref: ref} if _, err := client.Sync(opts, cmd.OutOrStdout()); err != nil { return fmt.Errorf("sync: %w", err) } return nil }, } cmd.Flags().StringVar(&configPath, "config", "", "client config path (default: "+client.ConfigEnv+" env, user config, or platform default)") cmd.Flags().StringVar(&repoURL, "repo", "", "work repository URL or path — overrides any config, works without one") cmd.Flags().StringVar(&ref, "ref", "", "branch or tag to pull (requires --repo)") return cmd }