Documentation
¶
Overview ¶
Package workspace owns the directories a coding session runs in: the project roots a user registers, and the scratch directories the server generates for standalone chats. Path cleaning lives here alongside the scratch guard that depends on it, because that guard is the only thing standing between forged session metadata and a recursive delete of a real project.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalid = errors.New("workspace: invalid workspace")
ErrInvalid reports a path that cannot be used as a workspace root.
Functions ¶
func Clean ¶
Clean resolves a path to an absolute, symlink-free, lexically clean form. Resolution failures are tolerated so a path that does not exist yet still normalizes; callers that require an existing directory use Validate.
func EnsureDirectories ¶
EnsureDirectories creates the fixed layout every scratch workspace has. It is idempotent so a restored session can repair a partially deleted tree.
Types ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is the durable list of project roots shown in the sidebar. It is persisted separately from sessions so an empty project can stay registered.
Lock ordering: a caller that owns both a session lock and this registry must always take the session lock first. Registry never calls back into session code, which keeps that ordering trivially satisfiable.
func NewRegistry ¶
NewRegistry restores the registry from indexPath. Entries whose paths no longer normalize are dropped rather than failing startup, matching how the sidebar has always tolerated a project that moved.
func (*Registry) Discard ¶
Discard undoes an Ensure that was never persisted. It is only correct for a path Ensure reported as newly added.
func (*Registry) Ensure ¶
Ensure adds a project root in memory without persisting it, reporting whether this call was the one that added it. Creating a session registers its workspace and writes both indexes as one unit, so the caller flushes with Save and undoes a failure with Discard.
func (*Registry) List ¶
List returns registered projects newest-added first, including projects that currently have no conversations.
func (*Registry) Register ¶
Register validates a project root and persists it. Registering a path that is already present is a no-op that returns the existing entry.
type Scratch ¶
type Scratch struct {
// contains filtered or unexported fields
}
Scratch generates and reclaims the server-owned directories that standalone chat sessions run in. These are not registered projects: they are never listed in the sidebar and are created and destroyed with their session.
func NewScratch ¶
NewScratch returns the scratch manager rooted under the product data directory. Every generated path lives exactly two levels below root.
func (*Scratch) Create ¶
Create makes the directory tree for one session and returns its cleaned path. A partially created tree is removed rather than left behind.