fs

package
v0.1.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package fs provides filesystem-backed workspace stores.

It implements resource store, knowledge store, and state store variants.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KnowledgeStore

type KnowledgeStore struct {
	// contains filtered or unexported fields
}

KnowledgeStore is a filesystem-backed implementation of workspace.KnowledgeStore.

func NewKnowledgeStore

func NewKnowledgeStore(runtimeRoot string) *KnowledgeStore

NewKnowledgeStore creates an FS-backed KnowledgeStore. If runtimeRoot is empty it defaults to workspace.RuntimeRoot().

func (*KnowledgeStore) DBPath

func (s *KnowledgeStore) DBPath(_ context.Context) (string, error)

DBPath returns the application database path.

func (*KnowledgeStore) IndexBasePath

func (s *KnowledgeStore) IndexBasePath(_ context.Context, user string) (string, error)

IndexBasePath returns the base path for a user's embedding index.

func (*KnowledgeStore) SnapshotBasePath

func (s *KnowledgeStore) SnapshotBasePath(_ context.Context) (string, error)

SnapshotBasePath returns the base path for MCP snapshot caches.

type Option

type Option func(*Store)

Option configures an FS store.

func WithAFS

func WithAFS(fs afs.Service) Option

WithAFS overrides the default afs.Service used for file operations.

type StateStore

type StateStore struct {
	// contains filtered or unexported fields
}

StateStore is a filesystem-backed implementation of workspace.StateStore.

func NewStateStore

func NewStateStore(stateRoot string) *StateStore

NewStateStore creates an FS-backed StateStore. If stateRoot is empty it defaults to workspace.StateRoot().

func (*StateStore) StatePath

func (s *StateStore) StatePath(_ context.Context, scope string) (string, error)

StatePath returns the resolved state directory for a scope.

func (*StateStore) StateRoot

func (s *StateStore) StateRoot(_ context.Context) (string, error)

StateRoot returns the root state directory.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is a filesystem-backed implementation of workspace.Store.

func New

func New(root string, opts ...Option) *Store

New creates an FS-backed Store rooted at root. If root is empty it defaults to workspace.Root().

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, kind, name string) error

Delete removes whichever layout exists. No error if absent.

func (*Store) Entries

func (s *Store) Entries(ctx context.Context, kind string) ([]workspace.Entry, error)

Entries returns metadata-enriched listings for polling watchers.

func (*Store) Exists

func (s *Store) Exists(ctx context.Context, kind, name string) (bool, error)

Exists reports whether a resource exists in either layout.

func (*Store) List

func (s *Store) List(ctx context.Context, kind string) ([]string, error)

List returns the names of all resources of the given kind.

func (*Store) Load

func (s *Store) Load(ctx context.Context, kind, name string) ([]byte, error)

Load returns the raw bytes for a single resource. It tries the flat layout first (<root>/<kind>/<name>.yaml), then the nested layout (<root>/<kind>/<name>/<name>.yaml). Returns os.ErrNotExist if neither is found.

func (*Store) Root

func (s *Store) Root() string

Root returns the workspace root path.

func (*Store) Save

func (s *Store) Save(ctx context.Context, kind, name string, data []byte) error

Save creates or overwrites a resource using the flat layout.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL