workspace

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package workspace provides workspace management functionality.

Index

Constants

View Source
const (

	// DefaultWorkspaceName is the name of the protected default workspace.
	DefaultWorkspaceName = "workspace-default"
)

Variables

This section is empty.

Functions

func CreateWorkspaceInfo

func CreateWorkspaceInfo(workspacePath, name, repoURL string, cloned, failed int) error

CreateWorkspaceInfo writes workspace metadata to a .workspace-info file.

func ReadWorkspaceInfo

func ReadWorkspaceInfo(workspacePath string) (time.Time, error)

ReadWorkspaceInfo reads the creation time from a workspace's info file.

Types

type BranchResult

type BranchResult struct {
	RepoName      string
	BranchName    string
	UnpushedCount int
	Error         error
}

BranchResult describes the outcome of a branch operation.

type CreateInput

type CreateInput struct {
	Name       string
	OnProgress ProgressCallback
}

CreateInput contains all parameters for creating a workspace.

type CreateOutput

type CreateOutput struct {
	WorkspacePath string
	CreatedRepos  []RepoResult
	FailedRepos   []RepoResult
	SyncResults   []SyncResult
	WorkspaceType WorkspaceType
	AlreadyExists bool
}

CreateOutput contains the result of workspace creation.

type DeleteInput

type DeleteInput struct {
	Name           string
	DeleteBranches bool
}

DeleteInput contains all parameters for deleting a workspace.

type DeleteOutput

type DeleteOutput struct {
	WorkspacePath   string
	WorkspaceType   WorkspaceType
	DeletedBranches []BranchResult
	SkippedBranches []BranchResult
	Deleted         bool
}

DeleteOutput contains the result of workspace deletion.

type Manager

type Manager struct {
	WorkspacesDir string
	ReposDir      string
	ClaudeDir     string
}

Manager handles workspace operations including creation, deletion, and listing.

func NewManager

func NewManager(workspacesDir, reposDir, claudeDir string) *Manager

NewManager creates a new workspace manager with the specified directories.

func (*Manager) GetWorkspacePath

func (m *Manager) GetWorkspacePath(name string) (string, error)

GetWorkspacePath returns the filesystem path for a workspace by name.

func (*Manager) GetWorkspaceType

func (m *Manager) GetWorkspaceType(workspacePath string) (WorkspaceType, error)

GetWorkspaceType determines if a workspace uses clones or worktrees.

func (*Manager) GetWorkspaces

func (m *Manager) GetWorkspaces() ([]Workspace, error)

GetWorkspaces returns a list of all workspaces sorted by creation time.

type ProgressCallback added in v0.0.5

type ProgressCallback func(message string)

ProgressCallback is called to report progress during operations.

type RepoResult

type RepoResult struct {
	Name        string
	Path        string
	BranchName  string
	Error       error
	WasExisting bool
}

RepoResult describes the outcome of a single repository operation.

type RepositorySpec

type RepositorySpec struct {
	URL    string
	Name   string
	Branch string
}

RepositorySpec describes a repository to be included in a workspace.

func DiscoverMainRepos

func DiscoverMainRepos(reposDir string) ([]RepositorySpec, error)

DiscoverMainRepos finds all git repositories in the repos directory.

type Service

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

Service provides workspace management operations.

func NewService

func NewService(manager *Manager) *Service

NewService creates a new workspace service.

func (*Service) Create

func (s *Service) Create(input CreateInput) (CreateOutput, error)

Create creates a new workspace with repositories.

func (*Service) Delete

func (s *Service) Delete(input DeleteInput) (DeleteOutput, error)

Delete removes a workspace and optionally its associated branches.

func (*Service) DiscoverRepos

func (s *Service) DiscoverRepos() ([]RepositorySpec, error)

DiscoverRepos finds all git repositories in the repos directory.

func (*Service) GetPath

func (s *Service) GetPath(name string) (string, error)

GetPath returns the filesystem path for a workspace.

func (*Service) GetType

func (s *Service) GetType(workspacePath string) (WorkspaceType, error)

GetType determines if a workspace uses clones or worktrees.

func (*Service) List

func (s *Service) List() ([]WorkspaceInfo, error)

List returns all workspaces.

func (*Service) SyncMainRepos

func (s *Service) SyncMainRepos(repos []RepositorySpec) []SyncResult

SyncMainRepos fetches and pulls all main repositories in parallel.

type SyncResult

type SyncResult struct {
	RepoName string
	RepoPath string
	Fetched  bool
	Pulled   bool
	Error    error
}

SyncResult describes the outcome of syncing a main repository.

type Workspace

type Workspace struct {
	Name     string
	Path     string
	Projects []string
	Created  time.Time
}

Workspace represents a development workspace containing multiple repositories. This is a shared type used across packages (shell, ui, cmd).

type WorkspaceInfo

type WorkspaceInfo struct {
	Name      string
	Path      string
	Projects  []string
	Created   time.Time
	Type      WorkspaceType
	IsDefault bool
}

WorkspaceInfo extends the basic Workspace with additional metadata.

func ToWorkspaceInfo

func ToWorkspaceInfo(w Workspace) WorkspaceInfo

ToWorkspaceInfo converts a Workspace to WorkspaceInfo.

type WorkspaceType

type WorkspaceType string

WorkspaceType indicates whether a workspace uses clones or worktrees.

const (
	WorkspaceTypeClone    WorkspaceType = "clone"
	WorkspaceTypeWorktree WorkspaceType = "worktree"
)

Jump to

Keyboard shortcuts

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