Documentation
¶
Overview ¶
Package project manages on-disk project entries at `<BaseDir>/projects/<id>/` (managed) or any user-supplied absolute path (custom).
A Project is a bundle of: 1 folder (the agent cwd), defaults (preset/provider/system_addon), pinned sessions, icon, and display name. Sessions reference a project via Meta.ProjectID.
Storage layout:
projects/<id>/ meta.json — project meta (this package owns it) files/ — managed cwd (only when CustomPath is empty)
Index ¶
- Constants
- func Delete(layout config.Layout, id string) error
- func EnsureDefault(layout config.Layout, newID func() string) error
- func Exists(layout config.Layout, id string) bool
- func List(layout config.Layout) ([]string, error)
- func MigrateWorkspacesToProjects(layout config.Layout, newID func() string, ...) error
- func RelinkSessions(layout config.Layout, wsName, projectID string) error
- func ResolvePath(layout config.Layout, id string) (string, error)
- func SaveMeta(layout config.Layout, id string, meta Meta) error
- type CreateOptions
- type Defaults
- type Meta
- type Project
Constants ¶
const DefaultName = "default"
DefaultName is the name of the built-in project that ships with every fresh install.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
Delete removes the project metadata folder. For managed projects: also removes projects/<id>/ (including files/). For custom projects: the external folder is NOT touched. The "default" project cannot be deleted.
func EnsureDefault ¶
EnsureDefault creates the "default" project if no projects exist yet. Called from Bootstrap after migration so fresh installs always have a usable project.
func MigrateWorkspacesToProjects ¶
func MigrateWorkspacesToProjects(layout config.Layout, newID func() string, relink func(wsName, projectID string) error) error
MigrateWorkspacesToProjects is idempotent: it is a no-op when any project already exists on disk. Converts each workspace into a project with the same name, folder, and defaults, then relinks all sessions from workspace name to project_id.
Safety:
- Skips entirely if projects/ is non-empty.
- os.Rename is used for managed files/ — atomic on same-FS.
- Session meta is written only after the project is created.
- Legacy workspaces/ dir is kept on disk (not deleted) for safety.
func RelinkSessions ¶
RelinkSessions is the concrete relink callback used at boot: scans all session dirs and updates meta.project_id for sessions that reference the old workspace name. Uses a raw map round-trip to preserve all existing fields.
func ResolvePath ¶
ResolvePath returns the cwd for agent subprocesses bound to this project. Custom paths win; managed falls back to projects/<id>/files/.
Types ¶
type CreateOptions ¶
type CreateOptions struct {
ID string // pre-assigned UUID; generated if empty
Name string
Icon string
Description string
CustomPath string
Defaults Defaults
Tags []string
}
CreateOptions describes a new project.
type Defaults ¶
type Defaults struct {
Preset string `json:"preset,omitempty"`
Provider string `json:"provider,omitempty"`
SystemAddon string `json:"system_addon,omitempty"`
}
Defaults holds the preset/provider/system_addon that new sessions in this project inherit when not explicitly overridden.
type Meta ¶
type Meta struct {
ID string `json:"id"`
Name string `json:"name"`
Icon string `json:"icon,omitempty"`
Description string `json:"description,omitempty"`
CustomPath string `json:"custom_path,omitempty"`
Defaults Defaults `json:"defaults"`
PinnedSessions []string `json:"pinned_sessions,omitempty"`
Tags []string `json:"tags,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Meta is the persisted shape of a project.
type Project ¶
type Project struct {
Meta Meta `json:"meta"`
}
Project is the in-memory view: meta only (no session list — that lives in the registry).
func Create ¶
func Create(layout config.Layout, opt CreateOptions) (Project, error)
Create materialises the on-disk project entry. For managed projects (CustomPath=="") it also creates projects/<id>/files/. Custom paths are not created — they must already exist.