Documentation
¶
Index ¶
- Constants
- Variables
- func ArchiveSessionArtifacts(sess *session.Session) (archiveDir string, count int, err error)
- func ClearFocus(sess *session.Session) error
- func DefaultDestination(artifactType, sourceName string) string
- func DetectType(path string) string
- func DirForSession(sess *session.Session) string
- func DiscoverAssetBundle(sess *session.Session, primary string) []string
- func EncodeManifest(m *Manifest, sessionName string) ([]byte, error)
- func EnsureArtifactDir(base string) error
- func EnsureTheme(sess *session.Session) error
- func FocusedID(sess *session.Session) string
- func GenerateID(artifactType, title string, t time.Time) string
- func ManifestPath(sess *session.Session) string
- func NormalizeFolderPath(folder string) (string, error)
- func ParseReferencedAssets(file string, data []byte) []string
- func ParseTags(s string) []string
- func ReferencedAssets(sess *session.Session, a Artifact) []string
- func SafeJoin(base, rel string) (string, error)
- func SafeToOpenExternally(file string) bool
- func SaveManifest(sess *session.Session, m *Manifest) error
- func SecureExistingPath(base, rel string) (string, error)
- func SecureNewPath(base, rel string) (string, error)
- func Slugify(s string) string
- func SortNewestFirst(items []Artifact)
- func ValidateArtifact(a Artifact) error
- func ValidateManifest(m *Manifest) error
- func ValidateRelativePath(p string) error
- func ValidateRetention(r string) error
- func ValidateType(t string) error
- func WebPath(sessionName, file string) string
- type AddOptions
- type Artifact
- func Add(sess *session.Session, opts AddOptions) (out Artifact, err error)
- func AppendRegistered(m *Manifest, a Artifact) (Artifact, error)
- func Filter(artifacts []Artifact, opts FilterOptions) []Artifact
- func Find(m *Manifest, id string) (*Artifact, int)
- func Remove(sess *session.Session, id string) (out Artifact, err error)
- func ResolveFile(sess *session.Session, id string) (string, *Artifact, error)
- func SetRetention(sess *session.Session, id, retention string) (out Artifact, err error)
- func UpdateMetadata(sess *session.Session, id string, update MetadataUpdate) (out Artifact, err error)
- type FilterOptions
- type ListItem
- type Manifest
- type MetadataUpdate
Constants ¶
const ( ManifestVersion = 1 DirName = ".artifacts" ManifestName = "manifest.json" DefaultAgent = "unknown" DefaultRetention = "session" ArchiveRetention = "archive" )
const LockFileName = ".manifest.lock"
LockFileName is the manifest lock file inside the artifact directory. Every writer takes an exclusive flock on it before a read-modify-write of the manifest (see withManifestLock).
Variables ¶
var ErrIDExists = errors.New("artifact id already exists")
ErrIDExists reports that a manifest entry with the requested ID exists.
Functions ¶
func ArchiveSessionArtifacts ¶
func ClearFocus ¶
func DefaultDestination ¶
func DetectType ¶
func DirForSession ¶
func EncodeManifest ¶
EncodeManifest validates m for sessionName and returns the exact bytes SaveManifest writes.
func EnsureArtifactDir ¶
func EnsureTheme ¶
func ManifestPath ¶
func NormalizeFolderPath ¶
func ParseReferencedAssets ¶
func SafeToOpenExternally ¶
SafeToOpenExternally reports whether a file can be opened with the OS default application without risking code execution.
func SecureExistingPath ¶
SecureExistingPath resolves rel under base and rejects symlinks in any path component. It is intended for serving/copying/removing existing artifact files without letting a symlink inside .artifacts escape the artifact directory.
func SecureNewPath ¶
SecureNewPath resolves rel under base and rejects symlinks in parent components. If the destination exists and is a symlink, it is rejected too.
func SortNewestFirst ¶
func SortNewestFirst(items []Artifact)
func ValidateArtifact ¶
func ValidateManifest ¶
func ValidateRelativePath ¶
func ValidateRetention ¶
func ValidateType ¶
Types ¶
type AddOptions ¶
type Artifact ¶
type Artifact struct {
ID string `json:"id"`
Type string `json:"type"`
Title string `json:"title"`
File string `json:"file"`
Folder string `json:"folder,omitempty"`
Created time.Time `json:"created"`
Agent string `json:"agent,omitempty"`
Retention string `json:"retention,omitempty"`
Summary *string `json:"summary,omitempty"`
Tags []string `json:"tags,omitempty"`
Assets []string `json:"assets,omitempty"`
Focus bool `json:"focus,omitempty"`
}
Artifact describes one file under a session's .artifacts directory.
func AppendRegistered ¶
AppendRegistered validates a and appends it to m, for a file the caller has already written under the artifact directory. It performs no I/O, so callers that must avoid path-based (symlink-following) access can do the file system work themselves. It records no referenced assets (callers use it for untrusted content, whose references must not make removal delete other files). It fails if the ID is taken or another entry names the same file.
func Filter ¶
func Filter(artifacts []Artifact, opts FilterOptions) []Artifact
func ResolveFile ¶
ResolveFile returns the absolute on-disk path of the artifact with the given ID. The path is validated against the manifest and rejected if any component is a symlink, so callers (the desktop open/save bridge) can never be pointed at a file outside the session's artifact directory.
func SetRetention ¶
func UpdateMetadata ¶
type FilterOptions ¶
type ListItem ¶
ListItem is the agent/web-facing artifact shape with computed paths.
func WithComputedFields ¶
type Manifest ¶
type Manifest struct {
Version int `json:"version"`
Session string `json:"session"`
Artifacts []Artifact `json:"artifacts"`
}
Manifest indexes all artifacts for one devx session.
func NewManifest ¶
func ParseManifest ¶
ParseManifest parses and validates manifest bytes for sessionName. Callers that must not follow symlinks (e.g. the MCP artifact bridge) read the bytes themselves and use this for the same validation as LoadManifest.