services

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EnvironmentService

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

EnvironmentService handles environment detection and validation

func NewEnvironmentService

func NewEnvironmentService(filesystem *FilesystemService) *EnvironmentService

NewEnvironmentService creates a new environment service instance

func (*EnvironmentService) CheckDiskSpace

func (e *EnvironmentService) CheckDiskSpace(path string) (free, total uint64, err error)

CheckDiskSpace checks available disk space at the given path

func (*EnvironmentService) DetectEnvironment

func (e *EnvironmentService) DetectEnvironment() (*models.Environment, error)

DetectEnvironment detects and returns the current environment information

func (*EnvironmentService) GetRecommendations

func (e *EnvironmentService) GetRecommendations(env *models.Environment) []string

GetRecommendations returns environment setup recommendations

func (*EnvironmentService) GetSystemInfo

func (e *EnvironmentService) GetSystemInfo() map[string]string

GetSystemInfo returns system information

func (*EnvironmentService) InitializeGitRepository

func (e *EnvironmentService) InitializeGitRepository(path string) error

InitializeGitRepository initializes a new git repository

func (*EnvironmentService) IsInGitRepository

func (e *EnvironmentService) IsInGitRepository(path string) bool

IsInGitRepository checks if the current directory is inside a git repository

func (*EnvironmentService) ValidateProjectPath

func (e *EnvironmentService) ValidateProjectPath(path string, isHere bool) error

ValidateProjectPath validates that a path is suitable for project creation

func (*EnvironmentService) WaitForConnectivity

func (e *EnvironmentService) WaitForConnectivity(timeout time.Duration) error

WaitForConnectivity waits for internet connectivity to be restored

type FeatureService

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

func NewFeatureService

func NewFeatureService(filesystem FilesystemServiceInterface, git GitServiceInterface) *FeatureService

func (*FeatureService) CheckPrerequisites

func (f *FeatureService) CheckPrerequisites() (*models.FeatureCheckResult, error)

func (*FeatureService) CreateFeature

func (f *FeatureService) CreateFeature(description string) (*models.FeatureCreateResult, error)

func (*FeatureService) GetPaths

func (f *FeatureService) GetPaths() (*models.FeaturePathsResult, error)

func (*FeatureService) SetupPlan

func (f *FeatureService) SetupPlan() (*models.FeaturePlanResult, error)

func (*FeatureService) UpdateContext

func (f *FeatureService) UpdateContext(agentType string) (*models.FeatureContextResult, error)

func (*FeatureService) ValidateAgentType

func (f *FeatureService) ValidateAgentType(agentType string) error

type FeatureServiceInterface

type FeatureServiceInterface interface {
	CreateFeature(description string) (*models.FeatureCreateResult, error)
	SetupPlan() (*models.FeaturePlanResult, error)
	CheckPrerequisites() (*models.FeatureCheckResult, error)
	ValidateAgentType(agentType string) error
	UpdateContext(agentType string) (*models.FeatureContextResult, error)
	GetPaths() (*models.FeaturePathsResult, error)
}

type FilesystemService

type FilesystemService struct{}

FilesystemService handles file and directory operations

func NewFilesystemService

func NewFilesystemService() *FilesystemService

NewFilesystemService creates a new filesystem service instance

func (*FilesystemService) CopyFile

func (fs *FilesystemService) CopyFile(src, dest string) error

CopyFile copies a file from source to destination

func (*FilesystemService) CreateDirectory

func (fs *FilesystemService) CreateDirectory(path string) error

CreateDirectory creates a directory with the specified path

func (*FilesystemService) CreateTempDirectory

func (fs *FilesystemService) CreateTempDirectory(prefix string) (string, error)

CreateTempDirectory creates a temporary directory

func (*FilesystemService) DirectoryExists

func (fs *FilesystemService) DirectoryExists(path string) (bool, error)

DirectoryExists checks if a directory exists at the specified path

func (*FilesystemService) DownloadFile

func (fs *FilesystemService) DownloadFile(url, destination string) error

DownloadFile downloads a file from a URL (stub for interface compatibility)

func (*FilesystemService) ExtractZIP

func (fs *FilesystemService) ExtractZIP(zipPath, destDir string) error

ExtractZIP extracts a ZIP file to the specified destination directory

func (*FilesystemService) ExtractZIPWithFlatten

func (fs *FilesystemService) ExtractZIPWithFlatten(zipPath, destDir string) error

ExtractZIPWithFlatten extracts a ZIP file and flattens single root directories

func (*FilesystemService) ExtractZip

func (fs *FilesystemService) ExtractZip(src, dest string) error

ExtractZip extracts a ZIP file (alias for ExtractZIP)

func (*FilesystemService) FileExists

func (fs *FilesystemService) FileExists(path string) (bool, error)

FileExists checks if a file exists

func (*FilesystemService) GetDirectorySize

func (fs *FilesystemService) GetDirectorySize(path string) (int64, error)

GetDirectorySize calculates the total size of a directory and its contents

func (*FilesystemService) GetWorkingDirectory

func (fs *FilesystemService) GetWorkingDirectory() (string, error)

GetWorkingDirectory returns the current working directory

func (*FilesystemService) IsDirectoryEmpty

func (fs *FilesystemService) IsDirectoryEmpty(path string) (bool, error)

IsDirectoryEmpty checks if a directory is empty

func (*FilesystemService) IsWritable

func (fs *FilesystemService) IsWritable(path string) error

IsWritable checks if a directory is writable

func (*FilesystemService) ListDirectory

func (fs *FilesystemService) ListDirectory(path string) ([]string, error)

ListDirectory returns directory names as strings

func (*FilesystemService) ListDirectoryContents

func (fs *FilesystemService) ListDirectoryContents(path string) ([]os.DirEntry, error)

ListDirectoryContents returns the contents of a directory

func (*FilesystemService) MergeDirectories

func (fs *FilesystemService) MergeDirectories(srcDir, destDir string) error

MergeDirectories copies files from source directory to destination directory

func (*FilesystemService) ReadFile

func (fs *FilesystemService) ReadFile(path string) (string, error)

ReadFile reads content from a file as string

func (*FilesystemService) RemoveDirectory

func (fs *FilesystemService) RemoveDirectory(path string) error

RemoveDirectory removes a directory and all its contents

func (*FilesystemService) RemoveFile

func (fs *FilesystemService) RemoveFile(path string) error

RemoveFile removes a file at the specified path

func (*FilesystemService) WriteFile

func (fs *FilesystemService) WriteFile(path, content string) error

WriteFile writes content to a file

type FilesystemServiceInterface

type FilesystemServiceInterface interface {
	GetWorkingDirectory() (string, error)
	DirectoryExists(path string) (bool, error)
	IsDirectoryEmpty(path string) (bool, error)
	CreateDirectory(path string) error
	WriteFile(path, content string) error
	ReadFile(path string) (string, error)
	FileExists(path string) (bool, error)
	DownloadFile(url, destination string) error
	ExtractZip(src, dest string) error
	ListDirectory(path string) ([]string, error)
	CopyFile(src, dest string) error
}

FilesystemServiceInterface defines the interface for filesystem operations

type GitHubAsset

type GitHubAsset struct {
	ID                 int64     `json:"id"`
	Name               string    `json:"name"`
	Label              string    `json:"label"`
	ContentType        string    `json:"content_type"`
	Size               int64     `json:"size"`
	BrowserDownloadURL string    `json:"browser_download_url"`
	CreatedAt          time.Time `json:"created_at"`
	UpdatedAt          time.Time `json:"updated_at"`
}

GitHubAsset represents a GitHub release asset

type GitHubRelease

type GitHubRelease struct {
	ID          int64         `json:"id"`
	TagName     string        `json:"tag_name"`
	Name        string        `json:"name"`
	Body        string        `json:"body"`
	Draft       bool          `json:"draft"`
	Prerelease  bool          `json:"prerelease"`
	CreatedAt   time.Time     `json:"created_at"`
	PublishedAt time.Time     `json:"published_at"`
	Assets      []GitHubAsset `json:"assets"`
}

GitHubRelease represents a GitHub release from the API

type GitHubService

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

GitHubService handles interactions with the GitHub API

func NewGitHubService

func NewGitHubService() *GitHubService

NewGitHubService creates a new GitHub service instance

func NewGitHubServiceWithClient

func NewGitHubServiceWithClient(client *http.Client, repoOwner, repoName string) *GitHubService

NewGitHubServiceWithClient creates a new GitHub service with a custom HTTP client

func (*GitHubService) CheckConnectivity

func (g *GitHubService) CheckConnectivity() error

CheckConnectivity tests if GitHub API is accessible

func (*GitHubService) DownloadAsset

func (g *GitHubService) DownloadAsset(asset *GitHubAsset, writer io.Writer) error

DownloadAsset downloads a GitHub asset to the specified writer

func (*GitHubService) FindTemplateAsset

func (g *GitHubService) FindTemplateAsset(
	release *GitHubRelease,
) (*GitHubAsset, error)

FindTemplateAsset finds the template asset in the release

func (*GitHubService) GetLatestRelease

func (g *GitHubService) GetLatestRelease() (*GitHubRelease, error)

GetLatestRelease fetches the latest release from the GitHub repository

func (*GitHubService) GetRateLimitInfo

func (g *GitHubService) GetRateLimitInfo() (limit, remaining int, resetTime time.Time, err error)

GetRateLimitInfo returns information about GitHub API rate limiting

func (*GitHubService) GetTemplates

func (g *GitHubService) GetTemplates() (*models.Template, error)

GetTemplates retrieves the template

type GitService

type GitService struct{}

func NewGitService

func NewGitService() *GitService

func (*GitService) BranchExists

func (g *GitService) BranchExists(branchName string) (bool, error)

func (*GitService) CheckoutBranch

func (g *GitService) CheckoutBranch(branchName string) error

func (*GitService) CreateBranch

func (g *GitService) CreateBranch(branchName string) error

func (*GitService) GetCurrentBranch

func (g *GitService) GetCurrentBranch() (string, error)

func (*GitService) GetRepoRoot

func (g *GitService) GetRepoRoot() (string, error)

type GitServiceInterface

type GitServiceInterface interface {
	GetRepoRoot() (string, error)
	GetCurrentBranch() (string, error)
	CreateBranch(branchName string) error
	CheckoutBranch(branchName string) error
	BranchExists(branchName string) (bool, error)
}

type ProjectInitOptions

type ProjectInitOptions struct {
	Name             string
	Path             string
	AIAssistant      string
	IsHere           bool
	NoGit            bool
	IgnoreAgentTools bool
	Force            bool
}

ProjectInitOptions contains options for project initialization

type ProjectInitResult

type ProjectInitResult struct {
	Project     *models.Project
	Template    *models.Template
	Environment *models.Environment
	GitRepo     bool
	Warnings    []string
}

ProjectInitResult contains the result of project initialization

type ProjectService

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

ProjectService handles project initialization workflows

func NewProjectService

func NewProjectService(environment *EnvironmentService, template *TemplateService, filesystem *FilesystemService) *ProjectService

NewProjectService creates a new project service instance

func (*ProjectService) CheckProjectHealth

func (p *ProjectService) CheckProjectHealth(projectPath string) error

CheckProjectHealth performs health checks on an existing project

func (*ProjectService) EstimateProjectSize

func (p *ProjectService) EstimateProjectSize(aiAssistant string) (int64, error)

EstimateProjectSize estimates the total size a project will take after initialization

func (*ProjectService) GetNextSteps

func (p *ProjectService) GetNextSteps(result *ProjectInitResult) []string

GetNextSteps returns recommended next steps for the user

func (*ProjectService) InitializeProject

func (p *ProjectService) InitializeProject(options ProjectInitOptions) (*ProjectInitResult, error)

InitializeProject initializes a new project with the specified options

func (*ProjectService) ListAvailableTemplates

func (p *ProjectService) ListAvailableTemplates() (map[string]*models.Template, error)

ListAvailableTemplates returns information about all available templates

type TechInfo

type TechInfo struct {
	Language    string
	Framework   string
	Testing     string
	Database    string
	ProjectType string
}

type TemplateService

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

TemplateService handles template downloading and extraction

func NewTemplateService

func NewTemplateService(github *GitHubService, filesystem *FilesystemService) *TemplateService

NewTemplateService creates a new template service instance

func (*TemplateService) CalculateFileHash

func (t *TemplateService) CalculateFileHash(filePath string) (string, error)

CalculateFileHash calculates SHA256 hash of a file

func (*TemplateService) CheckTemplateUpdates

func (t *TemplateService) CheckTemplateUpdates(currentVersions map[string]string) (map[string]*models.Template, error)

CheckTemplateUpdates checks if there are newer versions of templates available

func (*TemplateService) CleanupTemporaryFiles

func (t *TemplateService) CleanupTemporaryFiles() error

CleanupTemporaryFiles removes any temporary files created during template operations

func (*TemplateService) CopyHiddenFolders

func (t *TemplateService) CopyHiddenFolders(cacheRoot, targetPath, aiAssistant string) error

CopyHiddenFolders copies cache directories to agent's hidden folder Unified logic works for all agents (claude, codex, gemini, etc.)

func (*TemplateService) CopyHiddenFoldersWithScan

func (t *TemplateService) CopyHiddenFoldersWithScan(cacheRoot, targetPath, aiAssistant string) error

CopyHiddenFoldersWithScan is the public fallback method

func (*TemplateService) CopyMemoryDirectly

func (t *TemplateService) CopyMemoryDirectly(cacheRoot, targetPath, aiAssistant string) error

copyMemoryDirectly is a fallback method when manifest is not available

func (*TemplateService) CopyMemoryToProject

func (t *TemplateService) CopyMemoryToProject(cacheRoot, targetPath, aiAssistant string) error

copyMemoryToProject copies only the memory folder from cache to project directory Uses CacheManifest for dynamic discovery and validation of memory content

func (*TemplateService) DownloadAndExtract

func (t *TemplateService) DownloadAndExtract(aiAssistant, targetPath string, isHere bool) (*models.Template, error)

DownloadAndExtract downloads a template for the specified AI assistant and extracts it to the target path Uses cache-first approach: checks cache validity, falls back to local templates if needed

func (*TemplateService) DownloadTemplateWithProgress

func (t *TemplateService) DownloadTemplateWithProgress(aiAssistant, targetPath string, isHere bool, progressCallback func(downloaded, total int64)) (*models.Template, error)

DownloadTemplateWithProgress downloads a template with progress tracking

func (*TemplateService) EstimateDownloadTime

func (t *TemplateService) EstimateDownloadTime(template *models.Template, speedBytesPerSecond int64) (estimatedSeconds int64)

EstimateDownloadTime estimates download time based on template size and connection speed

func (*TemplateService) GetAvailableTemplates

func (t *TemplateService) GetAvailableTemplates() (map[string]*models.Template, error)

GetAvailableTemplates returns information about available templates

func (*TemplateService) GetSpecKitVersion

func (t *TemplateService) GetSpecKitVersion() string

GetSpecKitVersion returns the current spec-kit version

func (*TemplateService) GetTemplateInfo

func (t *TemplateService) GetTemplateInfo(aiAssistant string) (*models.Template, error)

GetTemplateInfo returns information about a specific template without downloading

func (*TemplateService) ReadManifest

func (t *TemplateService) ReadManifest() (*models.CacheManifest, error)

ReadManifest reads and parses the cache manifest file from default cache location

func (*TemplateService) ResolveRoot

func (t *TemplateService) ResolveRoot() (string, error)

ResolveRoot returns the cache root directory path

func (*TemplateService) ValidateCache

func (t *TemplateService) ValidateCache(manifest *models.CacheManifest) error

ValidateCache validates the cache integrity by checking file hashes

func (*TemplateService) ValidateExtractedTemplate

func (t *TemplateService) ValidateExtractedTemplate(path string) error

ValidateExtractedTemplate performs basic validation on an extracted template

func (*TemplateService) ValidateTemplate

func (t *TemplateService) ValidateTemplate(aiAssistant string) error

ValidateTemplate checks if a template is valid and available

func (*TemplateService) WriteManifest

func (t *TemplateService) WriteManifest(manifest *models.CacheManifest) error

WriteManifest writes the cache manifest to the cache directory

Jump to

Keyboard shortcuts

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