apps

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIKeyApp

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

func NewAPIKeyApp

func NewAPIKeyApp(store apiKeyStore) *APIKeyApp

func (*APIKeyApp) Create

func (a *APIKeyApp) Create(ctx context.Context, workspaceID models.WorkspaceID, label string) (string, *models.APIKey, error)

Create mints a new API key in the given workspace. The plaintext token is returned exactly once — the store holds only the SHA-256 hash. Losing the plaintext means revoking and creating a new key.

func (*APIKeyApp) List

func (a *APIKeyApp) List(ctx context.Context, workspaceID models.WorkspaceID) ([]models.APIKeySummary, error)

List returns every API key scoped to the given workspace — metadata only, never the hash or plaintext.

func (*APIKeyApp) Resolve

func (a *APIKeyApp) Resolve(ctx context.Context, plaintext string) (*models.APIKey, error)

Resolve maps a presented plaintext token to its record. Returns Unauthorized when the token is malformed, unknown, or revoked. This is the entry point for the Auth middleware — called once per HTTP request, so a revocation takes effect on the *next* request; any request already past the middleware continues to completion.

func (*APIKeyApp) Revoke

func (a *APIKeyApp) Revoke(ctx context.Context, workspaceID models.WorkspaceID, keyID models.APIKeyID) error

Revoke soft-deletes a key by setting revoked_at. Revoked keys fail Resolve and can no longer authenticate requests.

type AdminApp

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

func NewAdminApp

func NewAdminApp(souls adminSoulApp, personas adminPersonaApp, rules adminRuleApp, brains adminBrainApp, procedures adminProcedureApp, skills adminSkillApp, state adminStateApp) *AdminApp

func (*AdminApp) Export

Export returns a ContentBundle for the given workspace. Entities are read through the app layer so business invariants apply. Returns an error only on store-layer failures or context cancellation.

func (*AdminApp) Import

Import applies a bundle to the workspace additively. Per-entity failures (dangling refs, validation errors) become warnings and do not abort. Returns an error only on unknown schema version, context cancellation, or store I/O that the caller cannot recover from.

type BrainApp

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

func NewBrainApp

func NewBrainApp(store brainStore, refs *RefChecker) *BrainApp

func (*BrainApp) Delete

func (a *BrainApp) Delete(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) error

func (*BrainApp) Get

func (a *BrainApp) Get(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Brain, error)

func (*BrainApp) List

func (a *BrainApp) List(ctx context.Context, workspaceID models.WorkspaceID) ([]models.Brain, error)

func (*BrainApp) Upsert

func (a *BrainApp) Upsert(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug, soulSlug, personaSlug models.Slug, ruleSlugs []models.Slug, procedureSlug models.Slug, skillSlugs []models.Slug, modelPrefs *models.ModelPrefs) (*models.Brain, error)

type ComposeApp

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

func NewComposeApp

func NewComposeApp(content composeContentStore, state composeStateResolver) *ComposeApp

func (*ComposeApp) Compose

type PersonaApp

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

func NewPersonaApp

func NewPersonaApp(store personaStore, refs *RefChecker) *PersonaApp

func (*PersonaApp) Delete

func (a *PersonaApp) Delete(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) error

func (*PersonaApp) Get

func (a *PersonaApp) Get(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Persona, error)

func (*PersonaApp) List

func (a *PersonaApp) List(ctx context.Context, workspaceID models.WorkspaceID) ([]models.Persona, error)

func (*PersonaApp) Upsert

func (a *PersonaApp) Upsert(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug, content string, bundledRules []models.Slug) (*models.Persona, error)

type ProcedureApp added in v0.6.0

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

func NewProcedureApp added in v0.6.0

func NewProcedureApp(store procedureStore) *ProcedureApp

func (*ProcedureApp) Delete added in v0.6.0

func (a *ProcedureApp) Delete(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) error

func (*ProcedureApp) Get added in v0.6.0

func (a *ProcedureApp) Get(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Procedure, error)

func (*ProcedureApp) List added in v0.6.0

func (a *ProcedureApp) List(ctx context.Context, workspaceID models.WorkspaceID) ([]models.Procedure, error)

func (*ProcedureApp) Upsert added in v0.6.0

func (a *ProcedureApp) Upsert(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug, content string) (*models.Procedure, error)

type RefChecker

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

RefChecker validates referential integrity across content entities.

func NewRefChecker

func NewRefChecker(souls refSoulStore, personas refPersonaStore, rules refRuleStore, procedures refProcedureStore, skills refSkillStore) *RefChecker

NewRefChecker creates a RefChecker with access to content stores.

func (*RefChecker) ValidateBrainRefs

func (r *RefChecker) ValidateBrainRefs(ctx context.Context, workspaceID models.WorkspaceID, soulSlug, personaSlug models.Slug, ruleSlugs []models.Slug, procedureSlug models.Slug) error

ValidateBrainRefs checks that all references in a brain exist. Returns a RefError with a map of invalid fields if any are missing.

func (*RefChecker) ValidateRuleSlugs

func (r *RefChecker) ValidateRuleSlugs(ctx context.Context, workspaceID models.WorkspaceID, slugs []models.Slug) error

ValidateRuleSlugs checks that all rule slugs exist. Used by PersonaApp to validate bundled rules on upsert.

func (*RefChecker) ValidateSkillSlugs added in v0.6.0

func (r *RefChecker) ValidateSkillSlugs(ctx context.Context, workspaceID models.WorkspaceID, slugs []models.Slug) error

ValidateSkillSlugs checks that all skill slugs exist in the workspace. Used by BrainApp on upsert when the brain attaches skills.

type RuleApp

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

func NewRuleApp

func NewRuleApp(store ruleStore) *RuleApp

func (*RuleApp) Delete

func (a *RuleApp) Delete(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) error

func (*RuleApp) Get

func (a *RuleApp) Get(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Rule, error)

func (*RuleApp) List

func (a *RuleApp) List(ctx context.Context, workspaceID models.WorkspaceID) ([]models.Rule, error)

func (*RuleApp) Upsert

func (a *RuleApp) Upsert(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug, entries []models.RuleEntry) (*models.Rule, error)

type SkillApp added in v0.6.0

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

func NewSkillApp added in v0.6.0

func NewSkillApp(store skillStore) *SkillApp

func (*SkillApp) Delete added in v0.6.0

func (a *SkillApp) Delete(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) error

func (*SkillApp) Get added in v0.6.0

func (a *SkillApp) Get(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Skill, error)

func (*SkillApp) List added in v0.6.0

func (a *SkillApp) List(ctx context.Context, workspaceID models.WorkspaceID) ([]models.Skill, error)

func (*SkillApp) Upsert added in v0.6.0

func (a *SkillApp) Upsert(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug, description, body string, triggers []string, version int, scope models.SkillScope) (*models.Skill, error)

Upsert creates or replaces a skill. Scope is required and selects the on-disk emit target (`project` for per-repo skills, `user` for organizational skills loaded across every Claude Code session). Triggers defaults to an empty slice when nil so the stored row always has a parseable JSON array. Version defaults to 1 on initial create; callers bump it to invalidate runtime caches.

type SoulApp

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

func NewSoulApp

func NewSoulApp(store soulStore) *SoulApp

func (*SoulApp) Delete

func (a *SoulApp) Delete(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) error

func (*SoulApp) Get

func (a *SoulApp) Get(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Soul, error)

func (*SoulApp) List

func (a *SoulApp) List(ctx context.Context, workspaceID models.WorkspaceID) ([]models.Soul, error)

func (*SoulApp) Upsert

func (a *SoulApp) Upsert(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug, content string) (*models.Soul, error)

type StateApp

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

func NewStateApp

func NewStateApp(store stateStore) *StateApp

func (*StateApp) DeleteState

func (a *StateApp) DeleteState(ctx context.Context, wsID models.WorkspaceID, scopeType models.ScopeType, referenceID string) error

DeleteState removes the layer override at the target scope. No-op if no override exists.

func (*StateApp) FindLayers

func (a *StateApp) FindLayers(ctx context.Context, wsID models.WorkspaceID, projectSlug string) ([]models.LayerOverride, error)

FindLayers returns all applicable layer overrides in precedence order (workspace first, then project if given). Layers that don't exist are simply omitted.

func (*StateApp) ListLayers added in v0.7.0

func (a *StateApp) ListLayers(ctx context.Context, wsID models.WorkspaceID) ([]models.LayerOverride, error)

ListLayers returns every layer override stored for the workspace, across all scopes. Used by export to round-trip the full layer chain without specifying which project to look at.

func (*StateApp) ResolveForScope

func (a *StateApp) ResolveForScope(ctx context.Context, wsID models.WorkspaceID, projectSlug string) (*models.EffectiveState, error)

ResolveForScope merges all applicable layers into an EffectiveState.

Merge rules:

  • Soul/Persona: last non-nil layer wins. nil = skip (no opinion), empty string = explicitly clear, value = set.
  • Rules: remove first, then add (no duplicates), applied per layer.
  • Skills: same shape as rules. There is no base set on the workspace row — the overlay is the source of truth. `brain use` writes the brain's skill list into SkillSlugsToAdd, mirroring how rules work.

func (*StateApp) SetState

func (a *StateApp) SetState(ctx context.Context, wsID models.WorkspaceID, scopeType models.ScopeType, referenceID string, partial *models.LayerOverride) error

SetState upserts the layer override at the target scope, merging the partial override with any existing override. Nil fields in the partial are preserved from the existing override. If the result is empty (all fields nil/empty), the override is deleted.

type VersionApp

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

func NewVersionApp

func NewVersionApp(store versionStore) *VersionApp

func (*VersionApp) GetContentVersion

func (a *VersionApp) GetContentVersion(ctx context.Context, workspaceID models.WorkspaceID, contentType models.ContentType, slug models.Slug, version int) (*models.ContentVersion, error)

GetContentVersion returns the full archived snapshot. Returns NotFound when the slug is unknown or the version does not exist.

func (*VersionApp) ListContentVersions

func (a *VersionApp) ListContentVersions(ctx context.Context, workspaceID models.WorkspaceID, contentType models.ContentType, slug models.Slug) ([]models.VersionSummary, error)

ListContentVersions returns archived versions newest-first. Returns NotFound when the slug was never upserted; returns an empty slice when the slug exists but has no archived versions yet.

type WorkspaceApp

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

func NewWorkspaceApp

func NewWorkspaceApp(store workspaceStore) *WorkspaceApp

func (*WorkspaceApp) Create

func (a *WorkspaceApp) Create(ctx context.Context, name string) (*models.Workspace, error)

func (*WorkspaceApp) Delete

func (a *WorkspaceApp) Delete(ctx context.Context, id models.WorkspaceID) error

Delete removes an empty workspace. Returns Conflict if the workspace still holds content — callers who want to drop the content first use Purge.

func (*WorkspaceApp) Get

func (*WorkspaceApp) GetByName

func (a *WorkspaceApp) GetByName(ctx context.Context, name string) (*models.Workspace, error)

GetByName resolves a user-facing workspace name to a workspace. Returns NotFound when no workspace carries that name.

func (*WorkspaceApp) List

func (a *WorkspaceApp) List(ctx context.Context) ([]models.Workspace, error)

func (*WorkspaceApp) Purge

func (a *WorkspaceApp) Purge(ctx context.Context, id models.WorkspaceID) error

Purge drops every row attached to a workspace (souls, personas, rules, brains, state, api keys) and then the workspace itself. Irreversible; the caller is expected to have confirmed.

func (*WorkspaceApp) Rename

func (a *WorkspaceApp) Rename(ctx context.Context, id models.WorkspaceID, newName string) (*models.Workspace, error)

Jump to

Keyboard shortcuts

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