Documentation
¶
Overview ¶
Fresh-fetch path for the prompt loader (M-AGENT-MCP M5).
`ailang prompt --source auto|mcp|embedded` lets agents (and humans) pull the latest re-rendered teaching prompt from mcp.ailang.sunholo.com instead of relying on whatever was //go:embed'd at compile time. The MCP server holds the canonical, version-pinned content; the embedded copy is the always-available offline fallback.
Determinism: --source=embedded is REQUIRED for reproducible eval runs and is what `auto` falls back to when MCP is unreachable, slow, or returns content tagged for a different AILANG version. The CLI never returns fresh-but-wrong-version content.
Index ¶
- func BuildInfo() string
- func EmbeddedSHA256() string
- func GetActiveVersion() (string, error)
- func ListVersions() ([]string, error)
- func LoadPrompt(version string) (string, error)
- func LoadPromptWithVersion(version string) (string, string, error)
- func SetEmbeddedFS(efs fs.FS)
- type FreshOptions
- type FreshResult
- type Source
- type VersionMetadata
- type VersionsManifest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildInfo ¶ added in v0.14.3
func BuildInfo() string
BuildInfo exposes the binary's resolved version (build info if available).
func EmbeddedSHA256 ¶ added in v0.14.3
func EmbeddedSHA256() string
EmbeddedSHA256 returns the sha256 of the embedded full prompt for the currently-active version, or empty when the embedded FS isn't initialized.
func GetActiveVersion ¶
GetActiveVersion returns the active version from versions.json
func ListVersions ¶
ListVersions returns all available prompt versions
func LoadPrompt ¶
LoadPrompt loads a prompt by version string. If version is empty or "latest", uses the active version from versions.json. Returns the prompt content as a string.
func LoadPromptWithVersion ¶ added in v0.14.2
LoadPromptWithVersion loads a prompt by version string and returns the resolved version ID. If version is empty or "latest", the active version is used and its ID is returned. Returns (content, versionUsed, error).
func SetEmbeddedFS ¶
SetEmbeddedFS sets the embedded filesystem for prompts This should be called from main() with the embedded FS
Types ¶
type FreshOptions ¶ added in v0.14.3
type FreshOptions struct {
// Source: auto/mcp/embedded. Empty defaults to auto.
Source Source
// Kind: "" (full) | "agent" | "devtools" | "compact". Mapped to the MCP
// prompt_get tool's "kind" arg.
Kind string
// Version: the AILANG version to pass as for_version. Empty resolves to
// the binary's compile-time version.
Version string
// MCPURL overrides the default endpoint (env: AILANG_MCP_URL).
MCPURL string
}
FreshOptions controls a fresh fetch.
type FreshResult ¶ added in v0.14.3
type FreshResult struct {
Content string
Source Source // actual source used (may differ from request when auto)
Version string // ailang version this content is tagged for
SHA256 string // content sha256 (first 7 chars used for display)
FromCache bool // true if served from ~/.ailang/cache/prompts/<ver>/
MCPNote string // human-readable note about the MCP attempt (drift, fallback reason)
}
FreshResult bundles the prompt content with metadata about how it was resolved, so the CLI can give the user/agent honest provenance.
func LoadPromptFresh ¶ added in v0.14.3
func LoadPromptFresh(ctx context.Context, opts FreshOptions, callerVersion string) (*FreshResult, error)
LoadPromptFresh resolves a prompt according to opts.Source.
auto: try MCP first; on any failure / version mismatch / timeout, fall
back to embedded silently. Result.MCPNote explains what happened.
mcp: MCP only. Returns error on failure (no embedded fallback). embedded: skip MCP entirely. Always works offline.
callerVersion is the binary's compile-time version (typically version.Version).
type Source ¶ added in v0.14.3
type Source string
Source selects where prompt content comes from.
const ( // SourceAuto prefers MCP when reachable AND its content is tagged for our // version, otherwise silently falls back to embedded. Default. SourceAuto Source = "auto" // SourceMCP forces MCP. Returns an error if unreachable or version // mismatch — useful for testing the wire path. SourceMCP Source = "mcp" // SourceEmbedded forces the //go:embed'd copy. Required for reproducible // eval runs and any offline-deterministic context. SourceEmbedded Source = "embedded" )
type VersionMetadata ¶
type VersionMetadata struct {
File string `json:"file"`
Hash string `json:"hash"`
Description string `json:"description"`
Created string `json:"created"`
Tags []string `json:"tags"`
Notes string `json:"notes"`
}
VersionMetadata represents metadata for a prompt version
func GetVersionMetadata ¶
func GetVersionMetadata(version string) (*VersionMetadata, error)
GetVersionMetadata returns metadata for a specific version
type VersionsManifest ¶
type VersionsManifest struct {
SchemaVersion string `json:"schema_version"`
Versions map[string]VersionMetadata `json:"versions"`
Active string `json:"active"`
Notes []string `json:"notes"`
}
VersionsManifest represents the versions.json file structure