Documentation
¶
Overview ¶
Package prompts is your prompt library, versioned, so nothing changes silently.
Every prompt belongs to exactly one org (the gateway-minted X-Org-Id, HIP-0026); tenant isolation is the org column, enforced on every query, so one tenant can never read or mutate another's prompts. Creating a prompt whose name already exists appends a new version — real, inspectable history, never a fabricated rollup.
Surface (all org-scoped; the shape console's PromptsModule consumes):
GET /v1/prompts list current prompts for the org -> {data:[PromptMeta]}
POST /v1/prompts create or add-a-version -> PromptDetail
GET /v1/prompts/metrics real per-prompt stats -> {data:[...]}
GET /v1/prompts/catalog the embedded read-only starter set -> {data:[...]}
GET /v1/prompts/:name prompt detail + version history -> PromptDetail
DELETE /v1/prompts/:name delete a prompt (+ its versions)
The store is SQLite in deps.DataDir (Base/SQLite-only mandate); it holds only template text + taxonomy, never a secret.
Index ¶
- func Mount(app cloud.Router, deps cloud.Deps) error
- func Shutdown() error
- type CatalogEntry
- type Prompt
- type Store
- func (s *Store) Close() error
- func (s *Store) CountVersions(ctx context.Context, org, name string) (int, error)
- func (s *Store) Delete(ctx context.Context, org, name string) (bool, error)
- func (s *Store) Get(ctx context.Context, org, name string) (Prompt, error)
- func (s *Store) List(ctx context.Context, org string) ([]Prompt, error)
- func (s *Store) Upsert(ctx context.Context, p Prompt) (Prompt, error)
- func (s *Store) Versions(ctx context.Context, org, name string) ([]Version, error)
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CatalogEntry ¶
type CatalogEntry struct {
Name string `json:"name"`
Type string `json:"type"`
Prompt string `json:"prompt"`
Tags []string `json:"tags"`
Labels []string `json:"labels"`
}
CatalogEntry is one starter prompt as the console browse UI consumes it.
type Prompt ¶
type Prompt struct {
ID string
Org string
Name string
Type string
Content string
Labels []string
Tags []string
Version int
CreatedAt int64
UpdatedAt int64
}
Prompt is the org-scoped, canonical record of a named, versioned prompt template. Tenant isolation is the org column, enforced at the query layer; the gateway-minted X-Org-Id (HIP-0026) selects the tenant. A prompt never stores a secret — it is template text plus taxonomy.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the prompt-library database. ONE SQLite file ({DataDir}/prompts.db) holds every org's records; tenancy is the org column. MaxOpenConns(1) serializes writes against the file lock.
func (*Store) CountVersions ¶
CountVersions returns the TRUE number of versions for (org,name) — the metrics count, unaffected by the history-response cap.
func (*Store) Upsert ¶
Upsert creates a prompt at version 1, or — when (org,name) already exists — advances it to a new version with the supplied content/type/labels/tags and appends the version-history row. The whole operation is one transaction, so a prompt's current row and its version log never drift. Returns the resulting (post-write) prompt.
type Version ¶
Version is the METADATA of one historical revision (its content lives in the prompt_versions row but is not returned in bulk — Red MED-1). Creating a prompt whose (org,name) already exists appends a new Version and advances the prompt's current Version — real, inspectable history, never fabricated.