Documentation
¶
Overview ¶
Package workspace confines filesystem access to a root directory.
Index ¶
- Constants
- func AgentsDir(root string) string
- func AgentsPath(root string, elem ...string) string
- func ContextStorePath(root string) string
- func GlobalContextStorePath(root string) string
- func LongPath(path string) string
- func MemoryDBPath(root string) string
- func NamespacePath(root string, elem ...string) string
- func OrgMemoryDBPath() string
- func SameExistingPath(a, b string) (bool, error)
- func SessionsDir(root string) string
- func SkillsDir(root string) string
- func UserHomeDir() (string, error)
- func UserSkillsDir() string
- func WorktreesDir(repoRoot string) string
- type Root
Constants ¶
const Namespace = ".mivia"
Namespace is the tool-scoped directory mivia owns beneath a root. Under a workspace root it holds project control and runtime files; under the user's home directory it holds user-level config and env files.
It is deliberately tool-scoped. The generic name mivia used before this belongs to no tool in particular, so claiming it collided with every other agent that assumed the same convention and gave users no way to tell whose files were whose. The directory is ordinary workspace content, readable and writable through the normal file tools like any other path.
Nothing outside this file may name a namespace directory. Resolving through one place is what keeps the name changeable and keeps a second convention from growing back a call site at a time.
Variables ¶
This section is empty.
Functions ¶
func AgentsPath ¶
AgentsPath joins elem beneath the project's .agents/ directory in root. Workspace skills live under .agents/skills/ so the development surface (skills, subagent roles, memories, rules, doctrines) stays together and is editable without touching the binary's own runtime namespace. The remaining runtime state (sessions, runs, worktrees, memory, hooks, policies, workflow definitions, agent role TOMLs) keeps living under Namespace.
func ContextStorePath ¶
ContextStorePath holds the always-on durable context checkpoint database for a specific workspace root. Callers that need the default install-wide store should use GlobalContextStorePath instead; this stays root-scoped for callers (workflow runs) that require per-workspace isolation.
func GlobalContextStorePath ¶
GlobalContextStorePath is the default durable chat/session store shared by every workspace on the machine, so a fresh install already has one history instead of a separate database per project directory. Sessions stay isolated inside this shared file by workspace ID (contextWorkspaceID), the same mechanism that lets managed worktrees share a store safely. An unavailable home directory falls back to root-scoped ContextStorePath so the caller still gets a usable path.
func LongPath ¶
LongPath returns path with every Windows short (8.3) name component expanded to its long form. On platforms without short names it returns the path unchanged.
Windows path APIs and git resolve short names to their long form, so a canonicality check that compares a raw path with its resolved form would reject every short-name path as non-canonical even though it names the same directory. Both sides of such a comparison must use the same rendering, which is what LongPath provides.
func MemoryDBPath ¶
MemoryDBPath is the default project-scoped memory database (plan 68). A repo owner may point [memory] store_path at a tracked path instead and commit memories with the repository.
func NamespacePath ¶
NamespacePath joins elem beneath the namespace directory in root. An empty root resolves relative to the process working directory.
func OrgMemoryDBPath ¶
func OrgMemoryDBPath() string
OrgMemoryDBPath is the user-level org-scoped memory database. An unavailable home directory yields an empty path so callers can disable the org store.
func SameExistingPath ¶
SameExistingPath reports whether two existing paths name the same file.
func SkillsDir ¶
SkillsDir holds workspace skill definitions as <name>/SKILL.md. Skills live under the project's .agents/skills/ directory so the development surface is editable as ordinary workspace content and shares no path with the binary's own runtime namespace (.mivia).
func UserHomeDir ¶
UserHomeDir returns the user-home directory. HOME is a cross-platform override for tests and portable automation.
func UserSkillsDir ¶
func UserSkillsDir() string
UserSkillsDir holds user-level skill definitions in the user's own .mivia home namespace (a sibling, not a child, of the project .agents/ surface). An unavailable home directory yields an empty path so callers can warn and continue without treating optional user customization as a startup failure.
func WorktreesDir ¶
WorktreesDir holds git worktree checkouts managed by mivia.
Types ¶
type Root ¶
type Root struct {
// Abs is the absolute, cleaned, symlink-evaluated root path.
Abs string
// LexicalAbs is the absolute, cleaned root path exactly as the caller
// named it, BEFORE symlink evaluation; the blocklist's lexical check
// derives workspace-relative names from it so an absolute path spelled
// through a symlink alias of the root maps to the same relative name as
// the direct spelling.
LexicalAbs string
// Unrestricted lifts the workspace escape check: file tools may resolve
// paths anywhere on the filesystem, not only under Abs. Set only by the
// operator-level `mivia chat --full-disk` flag (OpenFullDisk) - never by
// workspace config, so a repository cannot grant itself full disk access.
// The operator-invocation-only provenance is the security property; keep
// it that way.
Unrestricted bool
}
Root is a resolved workspace directory.
func OpenFullDisk ¶
OpenFullDisk resolves rootPath like Open but sets Unrestricted, allowing file tools to operate anywhere on the filesystem. Must only be called when the operator explicitly requested full disk access (e.g. --full-disk flag), never from workspace config.
func (*Root) LexicalRel ¶
LexicalRel returns the clean workspace-relative form of userPath without resolving symlinks. Rel reports where a request lands; LexicalRel reports the path the caller named, so a deny list can refuse a blocked name even when an in-workspace symlink would redirect the write elsewhere; a name that cannot be expressed as a workspace-relative path is an error and callers treat that as denied (fail closed).