prompts

package
v1.5.71 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package prompts holds the slash-command registry assembly shared by the REPL (internal/cli/repl) and the forthcoming TUI (internal/cli/tui). It was sunk out of the repl package (#383) so both front-ends wire the same built-in, live-state, prompt-template and skill commands from one owner, avoiding drift between the two command surfaces.

The logic here is a verbatim move of repl's former private buildSlashRegistry/loadPromptPaths/promptTemplateSources (plus their register helpers), exported unchanged so REPL behavior is identical.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSlashRegistry

func BuildSlashRegistry(live *cli.LiveConfig, creds *provider.CredentialStore, skills []*runtime.Skill, srcs PromptTemplateSources) (*runtime.SlashRegistry, error)

BuildSlashRegistry assembles the slash-command registry: compile-time built-ins seeded by runtime.NewSlashRegistry, the live-state action commands (/model, /help) bound to live, user declarative templates loaded from ~/.golder/commands (or $GOLDER_HOME/commands), plus the pre-loaded skills — each surfaced as a "/skill-name" command (mirrors Claude Code's /skill invocation). A missing directory is not an error. Names that collide with a built-in are shadowed (the built-in wins) and reported on stderr. The skills slice is loaded once by setupAgentEnv (empty under --no-skills), so no /skill-name commands are registered when it is empty. creds may be nil, which disables "/model" live catalog discovery.

func CachedModelCatalog

func CachedModelCatalog(live *cli.LiveConfig) []string

CachedModelCatalog returns the live model catalog without touching the network: the session's already-fetched list when present, else a fresh on-disk entry (younger than the shared catalog TTL). A hit is marked on live so the rest of the session reuses it. Nil when neither cache has anything.

func CredentialAvailable

func CredentialAvailable(creds *provider.CredentialStore, name string) bool

CredentialAvailable reports whether any credential layer can supply a key for a provider. It is a presence probe: no value is read or returned.

func CredentialSummary

func CredentialSummary(creds *provider.CredentialStore, name string) string

CredentialSummary reports a provider's credential availability as a short, value-free label for listings and pickers: "set", "set via config file", "set via --api-key", "set via oauth", or "not set". It is a presence probe that never names which variable satisfied it — the listing already shows the candidate variables in their own column, so repeating one here is noise. creds may be nil, which probes the environment layer only.

func DecisionModelSpecs added in v1.3.0

func DecisionModelSpecs() []provider.ProviderSpec

DecisionModelSpecs returns the registry's decision-only endpoints, in registry order. They are not conversation providers, so no provider LIST carries them; a screen that explains the setup still names them, because their key and their proxy route are things the user configures. Callers show them in a section of their own — the /provider listing and the TUI picker both do.

func DefaultModelForProvider added in v1.4.2

func DefaultModelForProvider(providerName string) string

DefaultModelForProvider returns the effective default model for one provider: the model the user saved for that gateway, or the gateway's own built-in default when nothing was saved. The picker uses it so `(default)` describes what a switch to this gateway will actually start with, not only what was explicitly written to config.toml.

func DefaultModelName added in v1.4.2

func DefaultModelName() string

DefaultModelName returns the config.toml default model, or "" when the file does not set one. A read error reads as unset, like DefaultProviderName.

func DefaultProviderName added in v1.3.6

func DefaultProviderName() string

DefaultProviderName returns the config.toml default provider, or "" when the file does not set one. A read error reads as unset: a listing marks the default, it does not repair the file.

func DefaultThinkingLevelForProviderModel added in v1.5.2

func DefaultThinkingLevelForProviderModel(providerName, model string) agentcore.ThinkingLevel

DefaultThinkingLevelForProviderModel returns the saved level for one provider/model pair as a validated ThinkingLevel, or "" when none is saved.

func DefaultThinkingLevelName added in v1.4.2

func DefaultThinkingLevelName() string

DefaultThinkingLevelName returns the config.toml default reasoning level, or "" when the file does not set one.

func EnsureModelCatalog

func EnsureModelCatalog(live *cli.LiveConfig, creds *provider.CredentialStore) ([]string, error)

EnsureModelCatalog returns the live catalog, preferring the session cache, then a fresh disk cache, and only then the network.

func LoadPromptPaths

func LoadPromptPaths(paths []string) []runtime.SlashCommand

LoadPromptPaths loads prompt templates from each path (file or dir), skipping and warning on paths that don't exist or fail to read. It is tier-agnostic; the caller registers each result at the desired tier (AddSettings/AddCLI).

func ModelCatalogKey added in v1.3.1

func ModelCatalogKey(live *cli.LiveConfig) string

ModelCatalogKey names the gateway a model list belongs to (provider plus the endpoint it resolved to), or "" when the provider is unknown. Callers use it to tell whether a list fetched earlier still describes the live provider.

func ProviderEndpointParts added in v1.2.0

func ProviderEndpointParts(live *cli.LiveConfig, spec provider.ProviderSpec) (envVar, baseURL, source, proxy string)

ProviderEndpointParts breaks the endpoint summary into its structured pieces: the consulted base-url env var(s), the effective URL, where it came from ("default", a variable name, or "base_url override"), and the proxy routing. It backs both the one-line text listing (ProviderEndpointSummary) and the TUI picker's labeled detail block.

func ProviderEndpointSummary

func ProviderEndpointSummary(live *cli.LiveConfig, spec provider.ProviderSpec) string

ProviderEndpointSummary is shared by the terminal picker and text listing.

func ProvidersAvailableFirst

func ProvidersAvailableFirst(creds *provider.CredentialStore) []provider.ProviderSpec

ProvidersAvailableFirst returns the built-in provider specs ordered for display: providers with a credential found first (so the ready-to-use ones are quick to pick), then the rest. Both groups keep registry order.

func ProxyProvidersSelectedFirst

func ProxyProvidersSelectedFirst(selected []string) []provider.ProviderSpec

ProxyProvidersSelectedFirst keeps registry order within the selected and unselected groups. Both the picker and text listing use this ordering.

func RegisterBoundaryCommand added in v1.3.0

func RegisterBoundaryCommand(reg *runtime.SlashRegistry, lang func() string)

RegisterBoundaryCommand installs /boundary: which paths the read and write tools may already reach without asking.

These grants used to hang off /permissions as "writable" and "readable" subcommands, which put two different subjects on one command. The workspace boundary is consent — where data may come from, and where it may go — while the approval mode is about how calls are graded; a person auditing one is not auditing the other. The three doors now each speak for themselves: /trust for the directory, /boundary for the paths, /permissions for the mode. /grants stays the escape hatch that shows and edits every row of the one table.

lang reports the conversation language ("zh"/"en") so the output matches what the user is writing; a nil lang defaults to English.

func RegisterExtensionCommands added in v1.5.15

func RegisterExtensionCommands(reg *runtime.SlashRegistry, m *extensions.Manager)

func RegisterLiveCommands

func RegisterLiveCommands(reg *runtime.SlashRegistry, live *cli.LiveConfig, creds *provider.CredentialStore)

func RegisterPaneCommand added in v1.5.44

func RegisterPaneCommand(reg *runtime.SlashRegistry, tools []agentcore.AgentTool)

RegisterPaneCommand installs the user-authored pane lease path. Typing the slash command in one Agent's composer identifies that Agent without exposing an agent-id argument in the ordinary workflow.

func RegisterPermissionCommand

func RegisterPermissionCommand(reg *runtime.SlashRegistry, st *permissions.State, lang func() string)

RegisterPermissionCommand installs the /permissions action command: with an argument it switches the live approval mode (read-only / ask / auto / full-access); with none it lists the modes and marks the current one. The closure captures the shared state object, so the switch applies to the next tool call in both the plain REPL and the TUI. lang reports the language of the recent conversation ("zh"/"en") so the output matches what the user is writing; a nil lang defaults to English.

func SetDefaultModelText added in v1.4.2

func SetDefaultModelText(model string, level agentcore.ThinkingLevel, live *cli.LiveConfig) string

SetDefaultModelText persists model, its reasoning level and the provider that serves it, then reports. It is the text form of the model picker's `d` key and the `/model default` command.

func SetDefaultProviderText added in v1.3.6

func SetDefaultProviderText(name string, creds *provider.CredentialStore) string

SetDefaultProviderText persists name as the default provider and returns the report. It is exported because the TUI's provider picker offers the same action on a key, and both surfaces must say exactly the same thing.

The provider's own default model rides along when config.toml already pins a model: a model id belongs to the gateway that serves it, so leaving a stale one behind would pair the new provider with an id it does not know.

func SetDefaultThinkingText added in v1.4.2

func SetDefaultThinkingText(providerName, model string, level agentcore.ThinkingLevel) string

SetDefaultThinkingText persists only the reasoning level for one provider/model pair, leaving the model and provider alone. It backs the level picker's `d` key and `/model default think <level>`.

func SyncExtensionSkills added in v1.5.15

func SyncExtensionSkills(reg *runtime.SlashRegistry, m *extensions.Manager)

SyncExtensionSkills removes stale skill entries, but never a builtin or user template that won a name collision. Expansion rechecks admission too.

Types

type PromptTemplateSources

type PromptTemplateSources struct {
	Extensions *extensions.Manager
	Settings   []string
	CLI        []string
	// Disable (--no-prompt-templates) turns off all prompt-template discovery
	// (global, project, settings, CLI); built-ins and skills are unaffected.
	Disable bool
	// ProjectDir is the project-local prompts dir (.golder/prompts in the working
	// dir), loaded at the project tier only when ProjectTrusted is true.
	ProjectDir string
	// ProjectTrusted reports whether the working directory is trusted; project
	// templates load only then (mirrors pi: project prompts after the project is
	// trusted).
	ProjectTrusted bool
}

PromptTemplateSources carries the prompt-template discovery sources that BuildSlashRegistry loads beyond the global ~/.golder/{commands,prompts} dirs. Settings is the config.toml `prompts` array (TierSettings); CLI is the --prompt-template flag list (TierCLI, wired in #339). Each entry is a file or directory (loaded non-recursively). Missing paths are warned and skipped.

Jump to

Keyboard shortcuts

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