Files
agent-lib/internal/cli/root.go
T
m3ta-chiron 49dbcf469e feat: client sync core — config, pull, inventory, manifest, OpenCode target
- admin-protected client config (flag > AGENT_LIB_CONFIG > platform default),
  token used for basic auth only, redacted from all errors and files
- work-repo pull via go-git (bare cache clone + fetch, remote re-pointed on
  config change), clean failure keeps previous state
- inventory: own items + external areas from lockfile; MCP inventoried but
  never deployed
- manifest v1 records name/type/origin/revision/content-hash per item,
  deterministic bytes; folder hashes over sorted relpath+filehash lines so
  tree and disk hashes agree
- shared deploy package (atomic temp+rename, exec-bit preserving) now backs
  both curator materialization and client deployment
- sync validates and hashes everything before the first mutation; second run
  is a byte-level no-op
2026-08-23 10:31:00 +02:00

53 lines
1.1 KiB
Go

// Package cli wires the agent-lib command tree: vendor (curator side),
// sync/status (client side) and version.
package cli
import (
"fmt"
"io"
"os"
"runtime"
"github.com/spf13/cobra"
"github.com/m3tam3re/agent-lib/internal/version"
)
func NewRootCmd() *cobra.Command {
root := &cobra.Command{
Use: "agent-lib",
Short: "Curated agent content: vendor external sources, sync to OpenCode",
SilenceUsage: true,
SilenceErrors: true,
}
root.AddCommand(newVersionCmd())
root.AddCommand(newVendorCmd())
root.AddCommand(newValidateCmd())
root.AddCommand(newSyncCmd())
return root
}
func newVersionCmd() *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Print the agent-lib version",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
return printVersion(cmd.OutOrStdout())
},
}
}
func printVersion(w io.Writer) error {
_, err := fmt.Fprintf(w, "agent-lib %s (%s/%s)\n", version.Version, runtime.GOOS, runtime.GOARCH)
return err
}
func Execute() error {
if err := NewRootCmd().Execute(); err != nil {
fmt.Fprintln(os.Stderr, "error:", err)
return err
}
return nil
}