sidecar

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package sidecar coordinates skeeper's mirrored Git repository.

Index

Constants

View Source
const (
	// DirName is the sidecar clone directory in the main worktree.
	DirName = ".skeeper"
)

Variables

This section is empty.

Functions

func DefaultNamespace added in v0.1.1

func DefaultNamespace(repoName string) string

DefaultNamespace returns a safe sidecar namespace derived from a repo name.

func PrintJSON added in v0.2.0

func PrintJSON(w io.Writer, value any) error

PrintJSON writes a stable JSON payload for CLI renderers.

func UpdateGitignore

func UpdateGitignore(root string, namespaces []config.Namespace) error

UpdateGitignore appends or replaces skeeper's managed ignore block.

Types

type FSCKOptions added in v0.2.0

type FSCKOptions struct {
	JSON         bool
	SourceBranch string
}

FSCKOptions configures working-tree drift checks.

type FSCKResult added in v0.2.0

type FSCKResult struct {
	OK          bool                   `json:"ok"`
	Diagnostics []reconcile.Diagnostic `json:"diagnostics,omitempty"`
}

FSCKResult reports working-tree drift against the lock.

type HydrateResult

type HydrateResult struct {
	Restored []string `json:"restored"`
	Commit   string   `json:"commit"`
}

HydrateResult reports files restored by hydrate.

type InitDefaults

type InitDefaults struct {
	SidecarName string
	Visibility  string
	Namespace   string
	Patterns    []string
}

InitDefaults reports the values init should present before user overrides.

type InitOptions

type InitOptions struct {
	Sidecar      string
	SidecarName  string
	Visibility   string
	Namespace    string
	NamespaceSet bool
	Bootstrap    string
	Patterns     []string
}

InitOptions configures project bootstrap.

type InitResult

type InitResult struct {
	Root      string
	Sidecar   string
	Config    config.Config
	HookPath  string
	Gitignore string
}

InitResult reports files changed by init.

type LogOptions added in v0.2.0

type LogOptions struct {
	Latest       bool
	SourceBranch string
}

LogOptions configures sidecar history output.

type MergeDriverNamespace added in v0.2.0

type MergeDriverNamespace struct {
	Name   string                   `json:"name"`
	Branch string                   `json:"branch"`
	Digest lockfile.NamespaceDigest `json:"digest"`
	Files  int                      `json:"files"`
	Bytes  int64                    `json:"bytes"`
}

MergeDriverNamespace reports regenerated lock data for one namespace.

type MergeDriverOptions added in v0.2.0

type MergeDriverOptions struct {
	BasePath    string `json:"base_path,omitempty"`
	CurrentPath string `json:"current_path,omitempty"`
	OtherPath   string `json:"other_path,omitempty"`
}

MergeDriverOptions contains paths passed by Git's custom merge-driver protocol.

type MergeDriverResult added in v0.2.0

type MergeDriverResult struct {
	LockPath     string                 `json:"lock_path"`
	OutputPath   string                 `json:"output_path,omitempty"`
	Namespaces   []MergeDriverNamespace `json:"namespaces"`
	BasePath     string                 `json:"base_path,omitempty"`
	CurrentPath  string                 `json:"current_path,omitempty"`
	OtherPath    string                 `json:"other_path,omitempty"`
	ChangedFiles int                    `json:"changed_files"`
}

MergeDriverResult reports a regenerated lockfile merge result.

type MutateOptions added in v0.2.0

type MutateOptions struct {
	DryRun  bool
	JSON    bool
	Force   bool
	Commit  bool
	Message string
}

MutateOptions configures adopt/untrack.

type MutateResult added in v0.2.0

type MutateResult struct {
	Plan    reconcile.Plan             `json:"plan"`
	Changed []reconcile.TargetDecision `json:"changed"`
	DryRun  bool                       `json:"dry_run,omitempty"`
}

MutateResult reports adopt/untrack changes.

type NamespaceStatus added in v0.1.1

type NamespaceStatus struct {
	Name         string                   `json:"name"`
	Branch       string                   `json:"branch"`
	LastCommit   string                   `json:"last_commit,omitempty"`
	LastUnix     int64                    `json:"last_unix,omitempty"`
	Remote       string                   `json:"remote"`
	TrackedFiles int                      `json:"tracked_files"`
	LockedCommit string                   `json:"locked_commit,omitempty"`
	LockedDigest lockfile.NamespaceDigest `json:"locked_digest,omitempty"`
}

NamespaceStatus describes one namespace's sidecar state.

type NamespaceSyncResult added in v0.1.1

type NamespaceSyncResult struct {
	Name         string                   `json:"name"`
	Branch       string                   `json:"branch"`
	ChangedFiles int                      `json:"changed_files"`
	Committed    bool                     `json:"committed"`
	Commit       string                   `json:"commit"`
	Digest       lockfile.NamespaceDigest `json:"digest"`
	Files        int                      `json:"files"`
	Bytes        int64                    `json:"bytes"`
	Warnings     []reconcile.Diagnostic   `json:"warnings,omitempty"`
}

NamespaceSyncResult reports one namespace sync outcome.

type NamespaceVerification added in v0.2.0

type NamespaceVerification struct {
	Name     string                   `json:"name"`
	Branch   string                   `json:"branch"`
	Commit   string                   `json:"commit"`
	Digest   lockfile.NamespaceDigest `json:"digest"`
	Expected lockfile.NamespaceDigest `json:"expected_digest"`
	OK       bool                     `json:"ok"`
}

NamespaceVerification reports one namespace verification.

type PatternAddOptions added in v0.2.0

type PatternAddOptions struct {
	Namespace     string
	Exclude       []string
	AdoptExisting bool
	DryRun        bool
	JSON          bool
	Force         bool
	Commit        bool
	Message       string
}

PatternAddOptions configures pattern add.

type PatternAddResult added in v0.2.0

type PatternAddResult struct {
	ConfigPath string         `json:"config_path"`
	Gitignore  string         `json:"gitignore"`
	Plan       reconcile.Plan `json:"plan"`
	DryRun     bool           `json:"dry_run,omitempty"`
}

PatternAddResult reports pattern add.

type PatternTestOptions added in v0.2.0

type PatternTestOptions struct {
	Namespace string
	JSON      bool
}

PatternTestOptions configures pattern test.

type PatternTestResult added in v0.2.0

type PatternTestResult struct {
	Namespace string   `json:"namespace"`
	Glob      string   `json:"glob"`
	Matches   []string `json:"matches"`
}

PatternTestResult reports pattern test matches.

type RepairStatus added in v0.2.0

type RepairStatus struct {
	Transaction *state.Transaction `json:"transaction,omitempty"`
	Bypass      *state.Bypass      `json:"bypass,omitempty"`
}

RepairStatus reports local-only repair state.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service executes sidecar workflows.

func New

func New(runner gitexec.Runner) *Service

New returns a sidecar service.

func (*Service) Adopt added in v0.2.0

func (s *Service) Adopt(ctx context.Context, dir string, targets []string, opts MutateOptions) (MutateResult, error)

Adopt stops tracking files in the main index after sidecar coverage is pushed.

func (*Service) FSCK added in v0.2.0

func (s *Service) FSCK(ctx context.Context, dir string, opts FSCKOptions) (FSCKResult, error)

FSCK compares working-tree owned specs against skeeper.lock.

func (*Service) HooksCheck added in v0.2.0

func (s *Service) HooksCheck(ctx context.Context, dir string) (hooks.CheckResult, error)

HooksCheck checks managed hooks.

func (*Service) HooksInstall added in v0.2.0

func (s *Service) HooksInstall(ctx context.Context, dir string) (hooks.InstallResult, error)

HooksInstall installs managed hooks.

func (*Service) Hydrate

func (s *Service) Hydrate(ctx context.Context, dir string) (HydrateResult, error)

Hydrate clones the sidecar if needed and restores spec files from skeeper.lock.

func (*Service) Init

func (s *Service) Init(ctx context.Context, dir string, opts InitOptions) (InitResult, error)

Init creates the remote sidecar, clones it, writes config, and installs hooks.

func (*Service) InitDefaults

func (s *Service) InitDefaults(ctx context.Context, dir string) (InitDefaults, error)

InitDefaults returns deterministic defaults for the project at dir.

func (*Service) Log

func (s *Service) Log(ctx context.Context, dir, path string, options ...LogOptions) (string, error)

Log returns sidecar history for a mirrored file path.

func (*Service) MergeDriver added in v0.2.0

func (s *Service) MergeDriver(
	ctx context.Context,
	dir string,
	opts MergeDriverOptions,
) (MergeDriverResult, error)

MergeDriver regenerates skeeper.lock for Git merge-driver invocations.

func (*Service) PatternAdd added in v0.2.0

func (s *Service) PatternAdd(ctx context.Context, dir, glob string, opts PatternAddOptions) (PatternAddResult, error)

PatternAdd adds a namespace pattern and optionally adopts existing matches.

func (*Service) PatternTest added in v0.2.0

func (s *Service) PatternTest(
	ctx context.Context,
	dir, glob string,
	opts PatternTestOptions,
) (PatternTestResult, error)

PatternTest reports matches for a candidate glob.

func (*Service) RecordBypass added in v0.2.0

func (s *Service) RecordBypass(ctx context.Context, dir, reason string) error

RecordBypass records an audited pre-commit bypass.

func (*Service) RepairAbort added in v0.2.0

func (s *Service) RepairAbort(ctx context.Context, dir string) error

RepairAbort aborts a transaction before main-index mutation.

func (*Service) RepairResume added in v0.2.0

func (s *Service) RepairResume(ctx context.Context, dir string) (SyncResult, error)

RepairResume resumes by running a fresh sync with the recorded inputs.

func (*Service) RepairStatus added in v0.2.0

func (s *Service) RepairStatus(ctx context.Context, dir string) (RepairStatus, error)

RepairStatus returns current repair state.

func (*Service) Status

func (s *Service) Status(ctx context.Context, dir string) (Status, error)

Status returns a summary suitable for CLI display.

func (*Service) Sync

func (s *Service) Sync(ctx context.Context, dir string, opts SyncOptions) (SyncResult, error)

Sync mirrors main-tree spec files into the sidecar, pushes, writes, and stages skeeper.lock.

func (*Service) Untrack added in v0.2.0

func (s *Service) Untrack(ctx context.Context, dir string, targets []string, opts MutateOptions) (MutateResult, error)

Untrack removes main-index tracking while preserving sidecar coverage.

func (*Service) Verify added in v0.2.0

func (s *Service) Verify(ctx context.Context, dir string, opts VerifyOptions) (VerifyResult, error)

Verify validates skeeper.lock against the sidecar remote.

type Status

type Status struct {
	Sidecar     string                 `json:"sidecar"`
	Branch      string                 `json:"branch"`
	LockPresent bool                   `json:"lock_present"`
	LockCommit  string                 `json:"lock_commit,omitempty"`
	Namespaces  []NamespaceStatus      `json:"namespaces"`
	Transaction *state.Transaction     `json:"transaction,omitempty"`
	Bypass      *state.Bypass          `json:"bypass,omitempty"`
	Diagnostics []reconcile.Diagnostic `json:"diagnostics,omitempty"`
}

Status describes the current sidecar state.

type SyncOptions

type SyncOptions struct {
	DryRun  bool
	JSON    bool
	Commit  bool
	Message string
	Hook    bool
	Staged  bool
	Force   bool
	// Pull is accepted for older call sites; strict sync always fetches/rebases.
	Pull bool
}

SyncOptions configures a sync run.

type SyncResult

type SyncResult struct {
	ChangedFiles int                   `json:"changed_files"`
	Committed    bool                  `json:"committed"`
	Commit       string                `json:"commit,omitempty"`
	Namespaces   []NamespaceSyncResult `json:"namespaces"`
	LockPath     string                `json:"lock_path,omitempty"`
	DryRun       bool                  `json:"dry_run,omitempty"`
}

SyncResult reports a completed sync.

type VerifyOptions added in v0.2.0

type VerifyOptions struct {
	JSON         bool
	Hook         bool
	SourceBranch string
}

VerifyOptions configures lock verification.

type VerifyResult added in v0.2.0

type VerifyResult struct {
	OK          bool                    `json:"ok"`
	Namespaces  []NamespaceVerification `json:"namespaces"`
	Diagnostics []reconcile.Diagnostic  `json:"diagnostics,omitempty"`
}

VerifyResult reports lock verification.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL