workspace

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLinkNotFound = errors.New("link not found")

ErrLinkNotFound is returned by DeleteLink when no link with the given ID exists.

View Source
var ErrNoCurrentWorkspace = errors.New("no current workspace set; run `mimir workspace use <name>` first")

ErrNoCurrentWorkspace is returned when no active workspace has been set.

View Source
var ErrRepositoryNotFound = errors.New("repository not found in workspace")

ErrRepositoryNotFound is returned when the requested repository is not in the workspace.

View Source
var ErrWorkspaceNotFound = fmt.Errorf("workspace not found")

ErrWorkspaceNotFound is returned when a workspace DB file does not exist.

Functions

func AddRepository

func AddRepository(db *sql.DB, path string) (string, error)
func CreateLink(db *sql.DB, srcRepoID, srcSymbol, srcFile, dstRepoID, dstSymbol, dstFile, note string) (int64, error)

CreateLink inserts a new cross-repo symbol link into the workspace and returns the newly assigned link ID.

func DeleteLink(db *sql.DB, id int64) error

DeleteLink removes the link with the given ID. Returns ErrLinkNotFound when no link with that ID exists.

func DeleteWorkspace

func DeleteWorkspace(name string) error

DeleteWorkspace removes the workspace DB file for the named workspace. Returns ErrWorkspaceNotFound if the workspace does not exist.

func GetCurrentWorkspace

func GetCurrentWorkspace() (string, error)

GetCurrentWorkspace reads the active workspace name from the global config file. Returns ErrNoCurrentWorkspace if none has been set yet.

func GetMeta

func GetMeta(db *sql.DB, key string) (string, error)

func IndexWorkspace

func IndexWorkspace(db *sql.DB, concurrency int, rebuild bool) (<-chan RepoResult, error)

IndexWorkspace indexes all repositories in the workspace concurrently, running at most concurrency repos at the same time. Results are streamed to the returned channel in completion order. The channel is closed once all repos have been processed.

func IsSchemaMismatch

func IsSchemaMismatch(err error) bool

IsSchemaMismatch reports whether err (or any error in its chain) is a *SchemaMismatchError.

func ListWorkspaces

func ListWorkspaces() ([]string, error)

ListWorkspaces returns the names of all workspaces found on disk by scanning $XDG_CONFIG_HOME/mimir/workspaces/ for *.db files. Returns an empty slice (not an error) when the directory does not exist yet.

func OpenWorkspace

func OpenWorkspace(name string) (*sql.DB, error)

func RemoveRepository

func RemoveRepository(db *sql.DB, path string) error

RemoveRepository removes a repository from the workspace by its path. Returns ErrRepositoryNotFound if the repository is not in the workspace.

func SchemaVersion

func SchemaVersion() int

func SetCurrentWorkspace

func SetCurrentWorkspace(name string) error

SetCurrentWorkspace writes the active workspace name to the global config file.

func SetLinkMeta

func SetLinkMeta(db *sql.DB, linkID int64, key, value string) error

SetLinkMeta upserts a key/value metadata entry for the given link.

func WorkspaceDBPath

func WorkspaceDBPath(name string) (string, error)

WorkspaceDBPath returns the absolute path to the SQLite database file for the named workspace: $XDG_CONFIG_HOME/mimir/workspaces/<name>.db (or $HOME/.config/mimir/workspaces/<name>.db when XDG_CONFIG_HOME is unset).

func WorkspaceID

func WorkspaceID(name string) string

WorkspaceID returns the stable identifier for a workspace. Workspace names are user-chosen unique strings, so the name itself is the identifier — no hash disambiguation is needed (contrast with indexer.RepoID, which hashes filesystem paths to avoid basename collisions).

Types

type Link struct {
	ID        int64             `json:"id"`
	SrcRepoID string            `json:"src_repo_id"`
	SrcSymbol string            `json:"src_symbol"`
	SrcFile   string            `json:"src_file"`
	DstRepoID string            `json:"dst_repo_id"`
	DstSymbol string            `json:"dst_symbol"`
	DstFile   string            `json:"dst_file"`
	Note      string            `json:"note"`
	CreatedAt time.Time         `json:"created_at"`
	Meta      map[string]string `json:"meta,omitempty"`
}

Link represents a manually declared cross-repo symbol relationship stored in the workspace. It maps a symbol in one repository to a symbol in another.

func ListLinks(db *sql.DB, q LinkQuery) ([]Link, error)

ListLinks returns all links in the workspace matching the given query. All fields in the query are optional; empty string means no filter. Results are ordered by created_at. Each Link's Meta map is populated from the link_meta table.

type LinkQuery

type LinkQuery struct {
	SrcRepoID string // filter by source repo ID
	DstRepoID string // filter by destination repo ID
	SrcSymbol string // filter by source symbol name (exact match)
	DstSymbol string // filter by destination symbol name (exact match)
}

LinkQuery holds optional filters for ListLinks. Empty string fields are ignored (no filter applied).

type RepoResult

type RepoResult struct {
	Repo  Repository
	Stats indexer.IndexStats
	Err   error
}

RepoResult holds the outcome of indexing a single repository.

type Repository

type Repository struct {
	ID          string    `json:"id"`
	Path        string    `json:"path"`
	AddedAt     time.Time `json:"added_at"`
	LastIndexed time.Time `json:"last_indexed"`
}

func ListRepositories

func ListRepositories(db *sql.DB) ([]Repository, error)

type SchemaMismatchError

type SchemaMismatchError struct {
	Stored  int // version recorded in the existing workspace
	Current int // version expected by this binary
}

SchemaMismatchError is returned by OpenWorkspace when the on-disk workspace was created with a different schema version than the current binary expects. The caller should instruct the user to recreate the workspace.

func (*SchemaMismatchError) Error

func (e *SchemaMismatchError) Error() string

Jump to

Keyboard shortcuts

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