Documentation
¶
Index ¶
- type APIKeyApp
- func (a *APIKeyApp) Create(ctx context.Context, workspaceID models.WorkspaceID, label string) (string, *models.APIKey, error)
- func (a *APIKeyApp) List(ctx context.Context, workspaceID models.WorkspaceID) ([]models.APIKeySummary, error)
- func (a *APIKeyApp) Resolve(ctx context.Context, plaintext string) (*models.APIKey, error)
- func (a *APIKeyApp) Revoke(ctx context.Context, workspaceID models.WorkspaceID, keyID models.APIKeyID) error
- type AdminApp
- type BrainApp
- func (a *BrainApp) Delete(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) error
- func (a *BrainApp) Get(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Brain, error)
- func (a *BrainApp) List(ctx context.Context, workspaceID models.WorkspaceID) ([]models.Brain, error)
- func (a *BrainApp) Upsert(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug, ...) (*models.Brain, error)
- type ComposeApp
- type PersonaApp
- func (a *PersonaApp) Delete(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) error
- func (a *PersonaApp) Get(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Persona, error)
- func (a *PersonaApp) List(ctx context.Context, workspaceID models.WorkspaceID) ([]models.Persona, error)
- func (a *PersonaApp) Upsert(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug, ...) (*models.Persona, error)
- type ProcedureApp
- func (a *ProcedureApp) Delete(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) error
- func (a *ProcedureApp) Get(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Procedure, error)
- func (a *ProcedureApp) List(ctx context.Context, workspaceID models.WorkspaceID) ([]models.Procedure, error)
- func (a *ProcedureApp) Upsert(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug, ...) (*models.Procedure, error)
- type RefChecker
- func (r *RefChecker) ValidateBrainRefs(ctx context.Context, workspaceID models.WorkspaceID, ...) error
- func (r *RefChecker) ValidateRuleSlugs(ctx context.Context, workspaceID models.WorkspaceID, slugs []models.Slug) error
- func (r *RefChecker) ValidateSkillSlugs(ctx context.Context, workspaceID models.WorkspaceID, slugs []models.Slug) error
- type RuleApp
- func (a *RuleApp) Delete(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) error
- func (a *RuleApp) Get(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Rule, error)
- func (a *RuleApp) List(ctx context.Context, workspaceID models.WorkspaceID) ([]models.Rule, error)
- func (a *RuleApp) Upsert(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug, ...) (*models.Rule, error)
- type SkillApp
- func (a *SkillApp) Delete(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) error
- func (a *SkillApp) Get(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Skill, error)
- func (a *SkillApp) List(ctx context.Context, workspaceID models.WorkspaceID) ([]models.Skill, error)
- func (a *SkillApp) Upsert(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug, ...) (*models.Skill, error)
- type SoulApp
- func (a *SoulApp) Delete(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) error
- func (a *SoulApp) Get(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug) (*models.Soul, error)
- func (a *SoulApp) List(ctx context.Context, workspaceID models.WorkspaceID) ([]models.Soul, error)
- func (a *SoulApp) Upsert(ctx context.Context, workspaceID models.WorkspaceID, slug models.Slug, ...) (*models.Soul, error)
- type StateApp
- func (a *StateApp) DeleteState(ctx context.Context, wsID models.WorkspaceID, scopeType models.ScopeType, ...) error
- func (a *StateApp) FindLayers(ctx context.Context, wsID models.WorkspaceID, projectSlug string) ([]models.LayerOverride, error)
- func (a *StateApp) ResolveForScope(ctx context.Context, wsID models.WorkspaceID, projectSlug string) (*models.EffectiveState, error)
- func (a *StateApp) SetState(ctx context.Context, wsID models.WorkspaceID, scopeType models.ScopeType, ...) error
- type VersionApp
- type WorkspaceApp
- func (a *WorkspaceApp) Create(ctx context.Context, name string) (*models.Workspace, error)
- func (a *WorkspaceApp) Delete(ctx context.Context, id models.WorkspaceID) error
- func (a *WorkspaceApp) Get(ctx context.Context, id models.WorkspaceID) (*models.Workspace, error)
- func (a *WorkspaceApp) GetByName(ctx context.Context, name string) (*models.Workspace, error)
- func (a *WorkspaceApp) List(ctx context.Context) ([]models.Workspace, error)
- func (a *WorkspaceApp) Purge(ctx context.Context, id models.WorkspaceID) error
- func (a *WorkspaceApp) Rename(ctx context.Context, id models.WorkspaceID, newName string) (*models.Workspace, error)
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 ¶
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.
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 ¶
func (a *AdminApp) Export(ctx context.Context, wsID models.WorkspaceID) (*bundle.ContentBundle, error)
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 ¶
func (a *AdminApp) Import(ctx context.Context, wsID models.WorkspaceID, cb *bundle.ContentBundle) (*bundle.ImportResult, error)
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
type ComposeApp ¶
type ComposeApp struct {
// contains filtered or unexported fields
}
func NewComposeApp ¶
func NewComposeApp(content composeContentStore, state composeStateResolver) *ComposeApp
func (*ComposeApp) Compose ¶
func (a *ComposeApp) Compose(ctx context.Context, req models.ComposeRequest) (*models.ComposeResponse, error)
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)
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)
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
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) 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
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) 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) 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 (a *WorkspaceApp) Get(ctx context.Context, id models.WorkspaceID) (*models.Workspace, error)
func (*WorkspaceApp) GetByName ¶
GetByName resolves a user-facing workspace name to a workspace. Returns NotFound when no workspace carries that name.
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.