Files
agent-lib/internal/cli/root.go
T
m3ta-chiron 949a431c4c feat: status command + windows toast notifications
- status: read-only report of deployed/repository revision, pending changes,
  skipped items (with reasons), unrecognized local items, binary version;
  --json machine-readable; exit 1 when local modifications block repository
  updates (headless drift checks)
- sync/status share a read-only prepare() front half
- notify package: windows toast via PowerShell script (go-toast mechanism,
  zero deps, build-tag gated), noop on linux/macos; cross-compile verified
- toast fires exactly once per sync with warnings, never for routine syncs;
  notification failures are logged and never fail the sync (fail-open)
2026-08-23 10:40:25 +02:00

54 lines
1.2 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())
root.AddCommand(newStatusCmd())
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
}