feat(client): config search chain, --repo zero-config override, actionable missing-config error

sync/status now resolve the work repository from a fallback chain:
--repo flag > --config flag > AGENT_LIB_CONFIG env > user-level config
(XDG / AppData) > admin platform default. --repo works without any
config file; tokens fall back to AGENT_LIB_GIT_TOKEN/AGENT_LIB_GIT_USER
without ever overriding a configured token. A completely empty chain
yields an error listing every searched location, a minimal config
example and the --repo shortcut.

Closes beads: agent-lib-9o8
This commit is contained in:
2026-08-23 15:08:27 +02:00
parent 1b2fcb6fbb
commit 7070d8cc25
7 changed files with 627 additions and 31 deletions
+10 -6
View File
@@ -9,22 +9,26 @@ import (
)
func newSyncCmd() *cobra.Command {
var configPath string
var configPath, repoURL, ref string
cmd := &cobra.Command{
Use: "sync",
Short: "Pull the work repository and deploy its content to OpenCode",
Long: "Pulls the fleet-configured work repository (config from --config, " +
"AGENT_LIB_CONFIG, or the admin-protected platform default) and deploys " +
"skills, commands and agents into the OpenCode runtime paths. " +
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 {
if _, err := client.Sync(client.SyncOptions{ConfigPath: configPath}, cmd.OutOrStdout()); err != nil {
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 or platform default)")
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
}