base

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package base provides common repository helpers over workspace stores.

It implements generic list/load/save/delete behavior reused by typed repos.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repository

type Repository[T any] struct {
	// contains filtered or unexported fields
}

Repository generic CRUD for YAML/JSON resources stored under $AGENTLY_WORKSPACE/<kind>/.

func New

func New[T any](fs afs.Service, kind string) *Repository[T]

New constructs a repository for a specific workspace kind (e.g. "models").

func NewWithStore

func NewWithStore[T any](store workspace.Store, kind string) *Repository[T]

NewWithStore constructs a repository backed by a workspace.Store.

func (*Repository[T]) Add

func (r *Repository[T]) Add(ctx context.Context, name string, data []byte) error

Add uploads raw data.

func (*Repository[T]) Delete

func (r *Repository[T]) Delete(ctx context.Context, name string) error

Delete removes file.

func (*Repository[T]) Filename

func (r *Repository[T]) Filename(name string) string

Filename is a compatibility helper for legacy callers that do not pass context. New code should prefer ResolveFilename so lookup respects cancellation.

func (*Repository[T]) GetRaw

func (r *Repository[T]) GetRaw(ctx context.Context, name string) ([]byte, error)

GetRaw downloads raw bytes.

func (*Repository[T]) List

func (r *Repository[T]) List(ctx context.Context) ([]string, error)

List basenames (without extension).

func (*Repository[T]) Load

func (r *Repository[T]) Load(ctx context.Context, name string) (*T, error)

Load unmarshals YAML/JSON into *T.

func (*Repository[T]) ResolveFilename

func (r *Repository[T]) ResolveFilename(ctx context.Context, name string) (string, error)

ResolveFilename resolves a resource path using the caller context.

func (*Repository[T]) Save

func (r *Repository[T]) Save(ctx context.Context, name string, obj *T) error

Save (Add/overwrite) marshals struct to YAML.

Jump to

Keyboard shortcuts

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