prompts

package
v1.801.477 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Mount

func Mount(app cloud.Router, deps cloud.Deps) error

Mount wires the prompts surface onto app per HIP-0106. Complex flavour: it holds a package-global (mounted) so Shutdown can release the store, so it constructs the Service value directly rather than via cloud.Mount.

func Shutdown

func Shutdown() error

Shutdown closes the prompts store. Idempotent.

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 — the system namespace's "prompts" — holds every org's records; tenancy is the org column. MaxOpenConns(1) serializes writes against the file lock.

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying database.

func (*Store) CountVersions

func (s *Store) CountVersions(ctx context.Context, org, name string) (int, error)

CountVersions returns the TRUE number of versions for (org,name) — the metrics count, unaffected by the history-response cap.

func (*Store) Delete

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

Delete removes a prompt and its version history. Reports whether a row went.

func (*Store) Get

func (s *Store) Get(ctx context.Context, org, name string) (Prompt, error)

Get returns the current prompt for (org,name) or errNotFound.

func (*Store) List

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

List returns every current prompt for org, most-recently-updated first.

func (*Store) Upsert

func (s *Store) Upsert(ctx context.Context, p Prompt) (Prompt, error)

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.

func (*Store) Versions

func (s *Store) Versions(ctx context.Context, org, name string) ([]Version, error)

Versions returns bounded version-history METADATA for (org,name), newest first (content is NOT selected — Red MED-1). The cap means a prompt with an unbounded append history still yields a small, constant-size response.

type Version

type Version struct {
	Version   int
	Type      string
	CreatedAt int64
}

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.

Jump to

Keyboard shortcuts

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