codebase

package
v0.2.1 Latest Latest
Warning

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

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

Documentation

Overview

Package codebase provides codebase management functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileInfo

type FileInfo struct {
	Path       string    `json:"path"`
	Name       string    `json:"name"`
	IsDir      bool      `json:"is_dir"`
	Size       int64     `json:"size"`
	ModifiedAt time.Time `json:"modified_at"`
}

FileInfo represents information about a file or directory.

type FileStore

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

FileStore implements Store interface using file-based JSON storage. Each codebase metadata is stored as a JSON file.

func NewFileStore

func NewFileStore(basePath string) (*FileStore, error)

NewFileStore creates a new file-based store.

func (*FileStore) Create

func (s *FileStore) Create(ctx context.Context, codebase *types.Codebase) error

Create stores a new codebase metadata.

func (*FileStore) Delete

func (s *FileStore) Delete(ctx context.Context, id string) error

Delete removes a codebase metadata by ID.

func (*FileStore) Exists

func (s *FileStore) Exists(ctx context.Context, id string) (bool, error)

Exists checks if a codebase with the given ID exists.

func (*FileStore) Get

func (s *FileStore) Get(ctx context.Context, id string) (*types.Codebase, error)

Get retrieves a codebase by ID.

func (*FileStore) List

func (s *FileStore) List(ctx context.Context, ownerID string, limit, offset int) ([]*types.Codebase, error)

List retrieves all codebases for an owner.

func (*FileStore) Update

func (s *FileStore) Update(ctx context.Context, codebase *types.Codebase) error

Update updates an existing codebase metadata.

type Manager

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

Manager handles codebase operations including file management.

func NewManager

func NewManager(basePath string) (*Manager, error)

NewManager creates a new codebase manager.

func NewManagerWithStore

func NewManagerWithStore(basePath string, store Store) (*Manager, error)

NewManagerWithStore creates a manager with a custom store (useful for testing).

func (*Manager) CreateCodebase

func (m *Manager) CreateCodebase(ctx context.Context, req *types.CreateCodebaseRequest) (*types.Codebase, error)

CreateCodebase creates a new codebase.

func (*Manager) DeleteCodebase

func (m *Manager) DeleteCodebase(ctx context.Context, id string) error

DeleteCodebase deletes a codebase and all its files.

func (*Manager) DeleteFile

func (m *Manager) DeleteFile(ctx context.Context, codebaseID, filePath string) error

DeleteFile removes a file from the codebase.

func (*Manager) GetCodebase

func (m *Manager) GetCodebase(ctx context.Context, id string) (*types.Codebase, error)

GetCodebase retrieves a codebase by ID.

func (*Manager) GetCodebasePath

func (m *Manager) GetCodebasePath(ctx context.Context, id string) (string, error)

GetCodebasePath returns the file system path for a codebase.

func (*Manager) ListCodebases

func (m *Manager) ListCodebases(ctx context.Context, ownerID string, limit, offset int) ([]*types.Codebase, error)

ListCodebases lists codebases for an owner.

func (*Manager) ListFiles

func (m *Manager) ListFiles(ctx context.Context, codebaseID, path string, recursive bool) ([]FileInfo, error)

ListFiles lists files in a codebase directory.

func (*Manager) ReadFile

func (m *Manager) ReadFile(ctx context.Context, codebaseID, filePath string) (io.ReadCloser, error)

ReadFile opens a file for reading from the codebase.

func (*Manager) RefreshStats

func (m *Manager) RefreshStats(ctx context.Context, codebaseID string) error

RefreshStats recalculates stats for a codebase (public API).

func (*Manager) WriteFile

func (m *Manager) WriteFile(ctx context.Context, codebaseID, filePath string, content io.Reader) error

WriteFile writes content to a file in the codebase.

type MemoryStore

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

MemoryStore implements Store interface using in-memory storage. Useful for testing and development.

func NewMemoryStore

func NewMemoryStore() *MemoryStore

NewMemoryStore creates a new in-memory store.

func (*MemoryStore) Create

func (s *MemoryStore) Create(ctx context.Context, codebase *types.Codebase) error

Create stores a new codebase metadata.

func (*MemoryStore) Delete

func (s *MemoryStore) Delete(ctx context.Context, id string) error

Delete removes a codebase metadata by ID.

func (*MemoryStore) Exists

func (s *MemoryStore) Exists(ctx context.Context, id string) (bool, error)

Exists checks if a codebase with the given ID exists.

func (*MemoryStore) Get

func (s *MemoryStore) Get(ctx context.Context, id string) (*types.Codebase, error)

Get retrieves a codebase by ID.

func (*MemoryStore) List

func (s *MemoryStore) List(ctx context.Context, ownerID string, limit, offset int) ([]*types.Codebase, error)

List retrieves all codebases for an owner.

func (*MemoryStore) Update

func (s *MemoryStore) Update(ctx context.Context, codebase *types.Codebase) error

Update updates an existing codebase metadata.

type Store

type Store interface {
	// Create stores a new codebase metadata.
	Create(ctx context.Context, codebase *types.Codebase) error

	// Get retrieves a codebase by ID.
	Get(ctx context.Context, id string) (*types.Codebase, error)

	// List retrieves all codebases for an owner.
	// If ownerID is empty, returns all codebases.
	List(ctx context.Context, ownerID string, limit, offset int) ([]*types.Codebase, error)

	// Update updates an existing codebase metadata.
	Update(ctx context.Context, codebase *types.Codebase) error

	// Delete removes a codebase metadata by ID.
	Delete(ctx context.Context, id string) error

	// Exists checks if a codebase with the given ID exists.
	Exists(ctx context.Context, id string) (bool, error)
}

Store defines the interface for codebase metadata storage.

Jump to

Keyboard shortcuts

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