Documentation
¶
Index ¶
- Variables
- func AddRepository(db *sql.DB, path string) (string, error)
- func CreateLink(db *sql.DB, ...) (int64, error)
- func DeleteLink(db *sql.DB, id int64) error
- func DeleteWorkspace(name string) error
- func GetCurrentWorkspace() (string, error)
- func GetMeta(db *sql.DB, key string) (string, error)
- func IndexWorkspace(db *sql.DB, concurrency int, rebuild bool) (<-chan RepoResult, error)
- func IsSchemaMismatch(err error) bool
- func ListWorkspaces() ([]string, error)
- func OpenWorkspace(name string) (*sql.DB, error)
- func RemoveRepository(db *sql.DB, path string) error
- func SchemaVersion() int
- func SetCurrentWorkspace(name string) error
- func SetLinkMeta(db *sql.DB, linkID int64, key, value string) error
- func WorkspaceDBPath(name string) (string, error)
- func WorkspaceID(name string) string
- type Link
- type LinkQuery
- type RepoResult
- type Repository
- type SchemaMismatchError
- type ValidationResult
Constants ¶
This section is empty.
Variables ¶
var ErrLinkNotFound = errors.New("link not found")
ErrLinkNotFound is returned by DeleteLink when no link with the given ID exists.
var ErrNoCurrentWorkspace = errors.New("no current workspace set; run `mimir workspace use <name>` first")
ErrNoCurrentWorkspace is returned when no active workspace has been set.
var ErrRepositoryNotFound = errors.New("repository not found in workspace")
ErrRepositoryNotFound is returned when the requested repository is not in the workspace.
var ErrWorkspaceNotFound = fmt.Errorf("workspace not found")
ErrWorkspaceNotFound is returned when a workspace DB file does not exist.
Functions ¶
func CreateLink ¶
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 ¶
DeleteLink removes the link with the given ID. Returns ErrLinkNotFound when no link with that ID exists.
func DeleteWorkspace ¶
DeleteWorkspace removes the workspace DB file for the named workspace. Returns ErrWorkspaceNotFound if the workspace does not exist.
func GetCurrentWorkspace ¶
GetCurrentWorkspace reads the active workspace name from the global config file. Returns ErrNoCurrentWorkspace if none has been set yet.
func IndexWorkspace ¶
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 ¶
IsSchemaMismatch reports whether err (or any error in its chain) is a *SchemaMismatchError.
func ListWorkspaces ¶
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 RemoveRepository ¶
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 ¶
SetCurrentWorkspace writes the active workspace name to the global config file.
func SetLinkMeta ¶
SetLinkMeta upserts a key/value metadata entry for the given link.
func WorkspaceDBPath ¶
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 ¶
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 ¶
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"`
// Validation fields populated when --check is used.
// Pointer types allow omitempty to distinguish nil (not checked) from
// false/empty (checked but invalid), so JSON consumers can always tell
// whether --check was run.
SrcValid *bool `json:"src_valid,omitempty"`
SrcFileValid *bool `json:"src_file_valid,omitempty"`
SrcActualFile *string `json:"src_actual_file,omitempty"`
SrcError *string `json:"src_error,omitempty"`
DstValid *bool `json:"dst_valid,omitempty"`
DstFileValid *bool `json:"dst_file_valid,omitempty"`
DstActualFile *string `json:"dst_actual_file,omitempty"`
DstError *string `json:"dst_error,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.
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
type ValidationResult ¶ added in v0.3.0
type ValidationResult struct {
Link Link
}
ValidationResult holds the outcome of validating a single link. The Link field contains the original link data with validation fields populated in-place. It is not stored in the database.
func ValidateLink ¶ added in v0.3.0
func ValidateLink(db *sql.DB, link *Link) (*ValidationResult, error)
ValidateLink checks that the symbols and file paths in a link still exist in their respective repositories. It opens each repo's index and searches for the symbols to verify they are present and located at the recorded paths.
A non-nil error is returned only for unrecoverable workspace-level failures (e.g. the repositories table cannot be queried). Link-level problems — repo not registered, symbol not found, ambiguous symbol — are recorded in the SrcError/DstError fields of the result and do not cause a non-nil error.
The original Link data is preserved in result.Link.