Documentation
¶
Index ¶
- Constants
- func AnnotateRuntimeCompatibilityEquivalence(primary, compatibility *cobra.Command, review RuntimeCompatibilityEquivalence)
- func AnnotateRuntimeConstraints(cmd *cobra.Command, constraints RuntimeSchemaConstraints)
- func AnnotateRuntimeFlag(cmd *cobra.Command, flagName, propertyName, paramType string, required bool, ...)
- func AnnotateRuntimeFlagEnum(cmd *cobra.Command, flagName string, values ...string)
- func AnnotateRuntimeFlagExample(cmd *cobra.Command, flagName, example string)
- func AnnotateRuntimeFlagFormat(cmd *cobra.Command, flagName, format string)
- func AnnotateRuntimeFlagProperty(cmd *cobra.Command, flagName, propertyName string)
- func AnnotateRuntimeFlagRequiredWhen(cmd *cobra.Command, flagName, expression string)
- func AnnotateRuntimePositionals(cmd *cobra.Command, positionals ...RuntimeSchemaPositional)
- func AnnotateRuntimeRequiredFlags(cmd *cobra.Command, flagNames ...string)
- func AnnotateRuntimeToolMetadata(cmd *cobra.Command, title, description, source string)
- func AttachRuntimeSchema(cmd *cobra.Command, productID, toolName, source string)
- func BuildManualAgentSelectionEvalFixture(bound BoundCommandRegistry, hints ManualAgentHintSet) (ManualAgentSelectionFixture, ManualAgentSelectionReport, error)
- func EmbeddedCommandRegistrySourceHash() (string, error)
- func EmbeddedSchemaParameterBindings() (map[string]map[string]string, error)
- func ExcludeFromRuntimeSchema(cmd *cobra.Command)
- func NewMCPCommand(_ context.Context, _ CatalogLoader, _ executor.Runner, _ *pipeline.Engine) *cobra.Command
- func NewSchemaCommand(_ CatalogLoader) *cobra.Command
- func OverridePriority(cmd *cobra.Command) int
- func ParseManualAgentExampleArgv(input string) ([]string, error)
- func ReadFileArg(value string) (string, bool, error)
- func ReadStdin() (string, error)
- func ReadStdinIfPiped() (string, error)
- func RegisterRuntimeSchemaConstraints(canonicalPath string, constraints RuntimeSchemaConstraints)
- func RegisterRuntimeSchemaParameterMetadata(canonicalPath string, metadata RuntimeSchemaParameterMetadata)
- func RegisterSchemaHints(productID string, tools map[string]ToolSchemaHint)
- func ResolveInputSource(value string, flagName string, guard *StdinGuard) (string, error)
- func ReviewedDryRunCapabilities() (map[string]DryRunSpec, error)
- func RuntimeSchemaParameterMetadataDefinitions() map[string]RuntimeSchemaParameterMetadata
- func SetOverridePriority(cmd *cobra.Command, priority int)
- func StdinIsPipe() bool
- func ValidateEmbeddedRuntimeSchemaCompleteness(root *cobra.Command) error
- func ValidateEmbeddedSchemaParameterBindings() error
- func ValidateInputSchema(params map[string]any, schema map[string]any) error
- func ValidateManualAgentHintExamples(bound BoundCommandRegistry, hints ManualAgentHintSet) error
- func ValidateManualAgentHintSet(hints ManualAgentHintSet, expectedProducts, expectedTools map[string]bool) error
- func ValidateReviewedDryRunCapabilityDelivery(registry SchemaRegistry) error
- func ValidateSchemaDeliveryInvariants(source SchemaRegistry, snapshot SchemaCatalogSnapshot) error
- func ValidateSchemaParameterBindingDelivery(bound BoundCommandRegistry, registry SchemaRegistry) error
- func ValidateSchemaParameterBindingsSource(data []byte) error
- type AliasKind
- type BoundAlias
- type BoundCommandRegistry
- type BoundCommandSpec
- type CLIFlagHint
- type CanonicalProduct
- type Catalog
- type CatalogDegraded
- type CatalogDegradedReason
- type CatalogLoader
- type CommandRegistry
- type CommandSpec
- type DryRunSpec
- type EffectiveCommandRegistry
- type EnvironmentLoader
- type FieldCandidateProvenance
- type FieldProvenance
- type FlagKind
- type FlagSpec
- type InterfaceRefKey
- type InterfaceRefSpec
- type InterfaceRegistry
- type InterfaceRegistryEntry
- type InterfaceSpec
- type ManualAgentExampleDisposition
- type ManualAgentExampleDispositionSource
- type ManualAgentExampleExecution
- type ManualAgentExampleExecutionPlan
- func BuildManualAgentExampleExecutionPlan(bound BoundCommandRegistry, registry SchemaRegistry, hints ManualAgentHintSet) (ManualAgentExampleExecutionPlan, error)
- func ValidateEmbeddedManualAgentExampleDelivery(bound BoundCommandRegistry, registry SchemaRegistry) (ManualAgentExampleExecutionPlan, error)
- type ManualAgentExampleMode
- type ManualAgentExampleReasonCode
- type ManualAgentHintRevision
- type ManualAgentHintSet
- type ManualAgentProductHint
- type ManualAgentSelectionCase
- type ManualAgentSelectionFixture
- type ManualAgentSelectionReport
- type ManualAgentToolHint
- type ManualSchemaCommandHint
- type ManualSchemaHintReport
- type ManualSchemaHintSnapshot
- type ManualSchemaParameterHint
- type ParameterSchemaHint
- type ParameterSpec
- type ProductSpec
- type ResolvedSchemaBuild
- type RuntimeCompatibilityEquivalence
- type RuntimeSchemaCompletenessReport
- type RuntimeSchemaConstraints
- type RuntimeSchemaExclusion
- type RuntimeSchemaParameterMetadata
- type RuntimeSchemaPositional
- type RuntimeToolSpecInput
- type SafetySpec
- type SchemaCatalogBuildOptions
- type SchemaCatalogSnapshot
- type SchemaHintRegistry
- type SchemaIndex
- type SchemaMetadataLoadCounts
- type SchemaRegistry
- func (r SchemaRegistry) Index() (SchemaIndex, error)
- func (r SchemaRegistry) Sorted() SchemaRegistry
- func (r SchemaRegistry) ToOverviewPayload() (map[string]any, error)
- func (r SchemaRegistry) ToPayload() (map[string]any, error)
- func (r SchemaRegistry) ToSnapshotPayload() (SchemaSnapshotPayload, error)
- type SchemaSnapshotPayload
- type SchemaVisibility
- type SelectionSpec
- type StaticLoader
- type StdinGuard
- type ToolDescriptor
- type ToolIdentitySpec
- type ToolSchemaHint
- type ToolSpec
Constants ¶
const ( CatalogFixtureEnv = "DWS_CATALOG_FIXTURE" CacheDirEnv = "DWS_CACHE_DIR" PluginColdTimeoutEnv = "DWS_PLUGIN_COLD_TIMEOUT" )
const ( DryRunPreviewInvocation = "invocation" DryRunPreviewRequest = "request" DryRunPreviewPlan = "plan" DryRunPreviewDiff = "diff" )
const ( InterfaceModeMCP = "mcp" InterfaceModeLocal = "local" InterfaceModeComposite = "composite" InterfaceAvailable = "available" )
const SchemaCatalogSnapshotVersion = 1
Variables ¶
This section is empty.
Functions ¶
func AnnotateRuntimeCompatibilityEquivalence ¶ added in v1.0.52
func AnnotateRuntimeCompatibilityEquivalence(primary, compatibility *cobra.Command, review RuntimeCompatibilityEquivalence)
AnnotateRuntimeCompatibilityEquivalence records the same typed review on both sides of one independently executable compatibility pair. Invalid review data panics during command construction so production cannot silently accept an unreviewed handler mismatch.
func AnnotateRuntimeConstraints ¶ added in v1.0.52
func AnnotateRuntimeConstraints(cmd *cobra.Command, constraints RuntimeSchemaConstraints)
AnnotateRuntimeConstraints records command-level parameter relationships.
func AnnotateRuntimeFlag ¶ added in v1.0.52
func AnnotateRuntimeFlag(cmd *cobra.Command, flagName, propertyName, paramType string, required bool, _ string)
AnnotateRuntimeFlag adds parameter metadata to an already-registered flag. The metadata mirrors the runtime binding that produced the flag, allowing schema rendering to preserve MCP parameter names while displaying CLI flags.
func AnnotateRuntimeFlagEnum ¶ added in v1.0.52
AnnotateRuntimeFlagEnum records the accepted values for a flag.
func AnnotateRuntimeFlagExample ¶ added in v1.0.52
AnnotateRuntimeFlagExample records a valid representative CLI value.
func AnnotateRuntimeFlagFormat ¶ added in v1.0.52
AnnotateRuntimeFlagFormat records a machine-readable value format without changing the Cobra flag type.
func AnnotateRuntimeFlagProperty ¶ added in v1.0.52
AnnotateRuntimeFlagProperty records only the stable CLI flag to interface property binding. It intentionally does not copy required or constraints from an older Catalog into the current executable contract.
func AnnotateRuntimeFlagRequiredWhen ¶ added in v1.0.52
AnnotateRuntimeFlagRequiredWhen records a conditional CLI requirement. The expression is descriptive metadata and does not alter Cobra validation.
func AnnotateRuntimePositionals ¶ added in v1.0.52
func AnnotateRuntimePositionals(cmd *cobra.Command, positionals ...RuntimeSchemaPositional)
AnnotateRuntimePositionals records ordered positional arguments for agents.
func AnnotateRuntimeRequiredFlags ¶ added in v1.0.52
AnnotateRuntimeRequiredFlags records schema-only required semantics. Unlike cobra.MarkFlagRequired, it does not require the primary flag itself to be changed, so helper commands can keep accepting hidden --url/--id aliases.
func AnnotateRuntimeToolMetadata ¶ added in v1.0.52
AnnotateRuntimeToolMetadata preserves MCP-provided tool metadata on a Cobra leaf so `dws schema` can render richer descriptions without refetching.
func AttachRuntimeSchema ¶ added in v1.0.52
AttachRuntimeSchema records optional implementation-side identity evidence on a runnable command. Command discovery belongs exclusively to the reviewed CommandRegistry; the Cobra binder accepts an absent annotation and rejects an annotation that disagrees with the registry.
func BuildManualAgentSelectionEvalFixture ¶ added in v1.0.52
func BuildManualAgentSelectionEvalFixture(bound BoundCommandRegistry, hints ManualAgentHintSet) (ManualAgentSelectionFixture, ManualAgentSelectionReport, error)
BuildManualAgentSelectionEvalFixture turns every use_when and avoid_when entry into a typed, reproducible evaluation case and validates it against the exact BoundCommandRegistry.
Deterministic CI can prove full coverage, real command binding, and absence of literal contradictory expectations. Semantic command choice belongs to an opt-in live-model evaluation that consumes this fixture; this function never substitutes string matching for Agent behavior.
func EmbeddedCommandRegistrySourceHash ¶ added in v1.0.52
EmbeddedCommandRegistrySourceHash returns the stable semantic hash used by all generated downstream views.
func EmbeddedSchemaParameterBindings ¶ added in v1.0.52
EmbeddedSchemaParameterBindings returns a defensive copy of the reviewed, active public flag-to-interface bindings used by Catalog generation.
func ExcludeFromRuntimeSchema ¶ added in v1.0.52
ExcludeFromRuntimeSchema keeps a human-facing hint or redirect in --help while preventing it from being advertised as an executable agent tool.
func NewMCPCommand ¶
func NewMCPCommand(_ context.Context, _ CatalogLoader, _ executor.Runner, _ *pipeline.Engine) *cobra.Command
NewMCPCommand returns a stub command since the canonical discovery surface has been removed. The command tree is now built from plugins and static endpoint registration only.
func NewSchemaCommand ¶
func NewSchemaCommand(_ CatalogLoader) *cobra.Command
NewSchemaCommand serves the versioned embedded typed contract. A malformed release snapshot fails closed; falling back to the live Cobra tree would hide a broken delivery artifact and reintroduce a second Schema data path.
func OverridePriority ¶
OverridePriority delegates to cobracmd.OverridePriority.
func ParseManualAgentExampleArgv ¶ added in v1.0.52
ParseManualAgentExampleArgv exposes the same deliberately shell-free argv parser used by Manual Agent hint validation. Contract tests use it to run reviewed examples through Cobra without invoking a shell or maintaining a second parser with different escaping rules.
func ReadFileArg ¶
ReadFileArg reads the contents of a file referenced by the @filename syntax. Returns the original value unchanged if it does not start with "@" or is otherwise not a file-path-shaped value (e.g. "@所有人" is treated as plain text, not a path). Returns an error if the file cannot be read or exceeds the size limit.
Note: @- (stdin) is NOT handled here; use ResolveInputSource instead.
func ReadStdin ¶
ReadStdin reads all data from stdin unconditionally (up to maxStdinSize). Use this when the caller has explicitly requested stdin via @-.
func ReadStdinIfPiped ¶
ReadStdinIfPiped reads all data from stdin if it is a pipe (not a terminal). Returns empty string if stdin is a terminal or has no data.
func RegisterRuntimeSchemaConstraints ¶ added in v1.0.52
func RegisterRuntimeSchemaConstraints(canonicalPath string, constraints RuntimeSchemaConstraints)
RegisterRuntimeSchemaConstraints records reviewed cross-parameter CLI rules independently from the generated Catalog, preventing stale Catalog data from becoming the source of its own next generation.
func RegisterRuntimeSchemaParameterMetadata ¶ added in v1.0.52
func RegisterRuntimeSchemaParameterMetadata(canonicalPath string, metadata RuntimeSchemaParameterMetadata)
RegisterRuntimeSchemaParameterMetadata records strong, code-owned parameter semantics for one canonical command path.
func RegisterSchemaHints ¶ added in v1.0.52
func RegisterSchemaHints(productID string, tools map[string]ToolSchemaHint)
RegisterSchemaHints registers curated hints for one product. Keys in tools may be either RPC names ("send_ding_message") or canonical paths ("ding.send_ding_message"). Duplicate canonical paths panic during init so conflicting product hint files are caught early.
func ResolveInputSource ¶
func ResolveInputSource(value string, flagName string, guard *StdinGuard) (string, error)
ResolveInputSource resolves a flag value that may reference an external input source. It supports three forms:
- "@-" reads from stdin (requires StdinGuard claim)
- "@<path>" reads from the named file
- anything else returned unchanged
The flagName parameter is used only for error messages and StdinGuard tracking.
func ReviewedDryRunCapabilities ¶ added in v1.0.52
func ReviewedDryRunCapabilities() (map[string]DryRunSpec, error)
ReviewedDryRunCapabilities returns a defensive copy of the positive, reviewed capability registry for delivery gates.
func RuntimeSchemaParameterMetadataDefinitions ¶ added in v1.0.52
func RuntimeSchemaParameterMetadataDefinitions() map[string]RuntimeSchemaParameterMetadata
RuntimeSchemaParameterMetadataDefinitions returns a defensive copy for build-time contract validation.
func SetOverridePriority ¶
SetOverridePriority delegates to cobracmd.SetOverridePriority.
func StdinIsPipe ¶
func StdinIsPipe() bool
StdinIsPipe reports whether stdin is a pipe (not a terminal). This is a non-consuming check — it only inspects file mode via stat.
func ValidateEmbeddedRuntimeSchemaCompleteness ¶ added in v1.0.52
ValidateEmbeddedRuntimeSchemaCompleteness enforces the reviewed reverse command-tree contract used by generation and CI.
func ValidateEmbeddedSchemaParameterBindings ¶ added in v1.0.52
func ValidateEmbeddedSchemaParameterBindings() error
ValidateEmbeddedSchemaParameterBindings is the production validation gate for the reviewed binding source. Build and generator entrypoints call this before any candidate resolution so malformed input can never degrade to an empty binding set and flag-name inference.
func ValidateInputSchema ¶
ValidateInputSchema performs strict local validation for MCP tool inputs. It enforces required/type/enum checks and rejects unknown properties by default.
func ValidateManualAgentHintExamples ¶ added in v1.0.52
func ValidateManualAgentHintExamples(bound BoundCommandRegistry, hints ManualAgentHintSet) error
ValidateManualAgentHintExamples is the pre-generation validation layer. It binds every authored example to the exact reviewed primary/alias path and rejects flags and required arguments not accepted by the live Cobra command. Final typed constraints, dry-run capability, and exact delivery coverage are validated later by BuildManualAgentExampleExecutionPlan after generated Agent metadata exists. It never executes an example.
func ValidateManualAgentHintSet ¶ added in v1.0.52
func ValidateManualAgentHintSet(hints ManualAgentHintSet, expectedProducts, expectedTools map[string]bool) error
ValidateManualAgentHintSet validates the reviewed Agent prose and, when expected sets are supplied, requires exact product and canonical-tool coverage. It is intentionally independent from generated Catalog data.
func ValidateReviewedDryRunCapabilityDelivery ¶ added in v1.0.52
func ValidateReviewedDryRunCapabilityDelivery(registry SchemaRegistry) error
ValidateReviewedDryRunCapabilityDelivery proves that every positive source entry reaches the final typed registry and no serializer invents one. It deliberately imposes no minimum capability count or all-command coverage.
func ValidateSchemaDeliveryInvariants ¶ added in v1.0.52
func ValidateSchemaDeliveryInvariants(source SchemaRegistry, snapshot SchemaCatalogSnapshot) error
ValidateSchemaDeliveryInvariants proves that the serialized snapshot which will be embedded in the release binary is an exact delivery of source and has one content-identical ToolSpec behind every public Schema view. The snapshot is deliberately encoded and decoded through the production loader before any comparison is made.
This is a content gate, not a count gate: replacing one tool with another, consistently dropping a source field from every snapshot view, drifting a summary, or changing an alias payload while preserving all aggregate counts still fails.
func ValidateSchemaParameterBindingDelivery ¶ added in v1.0.52
func ValidateSchemaParameterBindingDelivery(bound BoundCommandRegistry, registry SchemaRegistry) error
ValidateSchemaParameterBindingDelivery proves that every reviewed binding input reaches the final public typed registry it was written for. Source validation alone cannot catch a typo that is internally hash-consistent; this production invariant joins the v3 manifest to the bound Cobra command and its delivered ParameterSpec before any Catalog is serialized.
func ValidateSchemaParameterBindingsSource ¶ added in v1.0.52
ValidateSchemaParameterBindingsSource validates an alternate source with the same strict decoder used in production. It is intended for source audit tools and tests; runtime resolution always consumes the embedded source.
Types ¶
type AliasKind ¶ added in v1.0.52
type AliasKind string
AliasKind records how a reviewed alias path is represented by Cobra. A Cobra alias resolves to the primary command pointer; a compatibility leaf is a separately registered (usually hidden) runnable command. Keeping the two forms explicit prevents downstream code from assuming that every alias has its own Cobra leaf.
type BoundAlias ¶ added in v1.0.52
type BoundAlias struct {
Path string
Command *cobra.Command
Kind AliasKind
Source string
ReviewReason string
}
BoundAlias is one reviewed alias path resolved against the live Cobra tree.
type BoundCommandRegistry ¶ added in v1.0.52
type BoundCommandRegistry struct {
Commands []BoundCommandSpec
ByCanonical map[string]BoundCommandSpec
ByCLIPath map[string]BoundCommandSpec
}
BoundCommandRegistry is the only command input the Schema assembler should consume. Every entry has passed exact path, executable-leaf, collision, and native-annotation consistency checks.
func BindEffectiveCommandRegistry ¶ added in v1.0.52
func BindEffectiveCommandRegistry(root *cobra.Command, effective EffectiveCommandRegistry) (BoundCommandRegistry, error)
BindEffectiveCommandRegistry resolves every registry path against the live Cobra tree. Registry entries may target hidden compatibility leaves when they are explicitly reviewed, but every target must be an actual runnable leaf. Native annotations are optional implementation evidence; when present they must exactly agree with the registry identity.
type BoundCommandSpec ¶ added in v1.0.52
type BoundCommandSpec struct {
CommandSpec
PrimaryCommand *cobra.Command
AliasCommands []BoundAlias
}
BoundCommandSpec joins one stable registry identity to its executable primary leaf and all executable alias paths.
type CLIFlagHint ¶ added in v1.0.48
type CLIFlagHint struct {
Shorthand string `json:"shorthand,omitempty"`
Alias string `json:"alias,omitempty"`
}
CLIFlagHint holds CLI flag alias/shorthand metadata for a tool parameter.
type CanonicalProduct ¶ added in v1.0.48
type CanonicalProduct struct {
ID string `json:"id"`
DisplayName string `json:"display_name"`
Description string `json:"description,omitempty"`
ServerKey string `json:"server_key"`
Endpoint string `json:"endpoint"`
Source string `json:"source,omitempty"`
Tools []ToolDescriptor `json:"tools"`
}
CanonicalProduct represents a single MCP product in the catalog.
func (CanonicalProduct) FindTool ¶ added in v1.0.48
func (p CanonicalProduct) FindTool(name string) (ToolDescriptor, bool)
FindTool returns the tool with the given RPC name.
type Catalog ¶ added in v1.0.48
type Catalog struct {
Products []CanonicalProduct `json:"products"`
}
Catalog holds the discovered MCP product surface.
func (Catalog) FindProduct ¶ added in v1.0.48
func (c Catalog) FindProduct(id string) (CanonicalProduct, bool)
FindProduct returns the product with the given ID.
type CatalogDegraded ¶ added in v1.0.9
type CatalogDegraded struct {
Reason CatalogDegradedReason
Hint string
ServerCount int
}
CatalogDegraded is returned by EnvironmentLoader.Load when discovery fails for a diagnosable reason. Callers that need graceful degradation (e.g. the runtime runner) can check errors.As and fall back to an empty catalog; callers like the schema command can surface the hint.
func (*CatalogDegraded) Error ¶ added in v1.0.9
func (e *CatalogDegraded) Error() string
type CatalogDegradedReason ¶ added in v1.0.9
type CatalogDegradedReason string
CatalogDegradedReason identifies why catalog discovery returned empty.
const ( DegradedUnauthenticated CatalogDegradedReason = "unauthenticated" DegradedMarketUnreachable CatalogDegradedReason = "market_unreachable" DegradedRuntimeAllFailed CatalogDegradedReason = "runtime_all_failed" )
type CatalogLoader ¶
CatalogLoader loads the canonical catalog.
func CatalogLoaderFrom ¶
func CatalogLoaderFrom(catalog Catalog, err error) CatalogLoader
CatalogLoaderFrom creates a CatalogLoader that returns a pre-loaded catalog and error.
type CommandRegistry ¶ added in v1.0.52
type CommandRegistry struct {
Commands []CommandSpec
ByCLIPath map[string]CommandSpec
ByCanonical map[string]CommandSpec
}
CommandRegistry is the decoded reviewed identity registry.
func ValidateCommandRegistrySource ¶ added in v1.0.52
func ValidateCommandRegistrySource(data []byte) (CommandRegistry, error)
ValidateCommandRegistrySource validates a compatibility --surface input and requires it to be semantically identical to the embedded reviewed registry. Generators may retain the flag for migration, but cannot use it to introduce a second identity source.
func (CommandRegistry) SourceHash ¶ added in v1.0.52
func (registry CommandRegistry) SourceHash() string
SourceHash hashes only stable identity, navigation, and reviewed exposure. Formatting, product order, provenance labels, and omitted default source_product_id/visibility values do not affect it.
type CommandSpec ¶ added in v1.0.52
type CommandSpec struct {
CanonicalPath string
SourceProductID string
PrimaryCLIPath string
Aliases []string
Visibility SchemaVisibility
Source string
ReviewReason string
}
CommandSpec is one reviewed command identity. Identity and navigation are deliberately kept together so no downstream renderer can independently invent a canonical name, primary path, or alias.
type DryRunSpec ¶ added in v1.0.52
type DryRunSpec struct {
PreviewKind string `json:"preview_kind"`
RemoteReads bool `json:"remote_reads,omitempty"`
}
DryRunSpec is a positive capability declaration. A nil ToolSpec.DryRun means the command has not declared reviewed --dry-run support; the Schema does not publish a negative or inferred capability in that case.
The whole object is one atomic contract field. Runtime execution remains owned by the command runner; Schema only projects the reviewed capability.
func (DryRunSpec) Validate ¶ added in v1.0.52
func (d DryRunSpec) Validate(canonical string) error
type EffectiveCommandRegistry ¶ added in v1.0.52
type EffectiveCommandRegistry struct {
Commands []CommandSpec
ByCLIPath map[string]CommandSpec
ByCanonical map[string]CommandSpec
}
EffectiveCommandRegistry is the reviewed registry after exact reviewed manual command additions have been merged. It remains independent of Cobra; binding is a separate fail-closed step.
func BuildEffectiveCommandRegistry ¶ added in v1.0.52
func BuildEffectiveCommandRegistry(root *cobra.Command) (EffectiveCommandRegistry, error)
BuildEffectiveCommandRegistry loads the reviewed registry and merges the embedded manual additions. Manual entries may only name an exact existing public runnable leaf. They may add a new command identity, but can never rewrite an existing registry identity or create an alias; aliases belong in the reviewed base CommandRegistry.
func (EffectiveCommandRegistry) SourceHash ¶ added in v1.0.52
func (registry EffectiveCommandRegistry) SourceHash() string
SourceHash includes reviewed manual additions because those entries are part of the effective identity registry delivered to downstream consumers.
type EnvironmentLoader ¶
type EnvironmentLoader struct {
LookupEnv func(string) (string, bool)
CatalogBaseURLOverride string
AuthTokenFunc func(context.Context) string
LoggerFunc func() *slog.Logger
}
EnvironmentLoader provides catalog loading. In the post-discovery architecture this always returns an empty catalog; endpoint resolution is handled by the direct runtime path.
func NewEnvironmentLoader ¶
func NewEnvironmentLoader() EnvironmentLoader
NewEnvironmentLoader creates an EnvironmentLoader with default settings.
type FieldCandidateProvenance ¶ added in v1.0.52
type FieldCandidateProvenance struct {
Value json.RawMessage `json:"value,omitempty"`
Source string `json:"source"`
SourceRef string `json:"source_ref,omitempty"`
Precedence string `json:"precedence,omitempty"`
ReviewReason string `json:"review_reason,omitempty"`
Selected *bool `json:"selected,omitempty"`
}
FieldCandidateProvenance retains one winning or non-winning source value.
type FieldProvenance ¶ added in v1.0.52
type FieldProvenance struct {
Value json.RawMessage `json:"value,omitempty"`
Source string `json:"source"`
SourceRef string `json:"source_ref,omitempty"`
Precedence string `json:"precedence,omitempty"`
Resolution string `json:"resolution"`
ReviewReason string `json:"review_reason,omitempty"`
Candidates []FieldCandidateProvenance `json:"candidates,omitempty"`
OverriddenCandidates []FieldCandidateProvenance `json:"overridden_candidates,omitempty"`
}
FieldProvenance records how one final field was selected. Value is raw JSON so provenance can describe strings, booleans and structured extension values without weakening the resolved ToolSpec itself.
type FlagSpec ¶
type FlagSpec struct {
PropertyName string
FlagName string
Alias string
Shorthand string
Kind FlagKind
Description string
}
func BuildFlagSpecs ¶
func BuildFlagSpecs(schema map[string]any, hints map[string]CLIFlagHint) []FlagSpec
type InterfaceRefKey ¶ added in v1.0.52
InterfaceRefKey is the exact, typed identity of an embedded MCP operation. It is deliberately independent from a CLI canonical path: multiple commands may explicitly project the same operation.
type InterfaceRefSpec ¶ added in v1.0.52
type InterfaceRefSpec struct {
ProductID string `json:"product_id"`
RPCName string `json:"rpc_name"`
}
InterfaceRefSpec identifies the backing operation, independently from the executable command identity.
type InterfaceRegistry ¶ added in v1.0.52
type InterfaceRegistry struct {
ByCanonical map[string]InterfaceRegistryEntry
ByInterfaceRef map[InterfaceRefKey][]string
}
InterfaceRegistry is the typed interface fact model. ByCanonical supports exact metadata navigation; ByInterfaceRef answers whether an explicitly selected (product_id, rpc_name) exists. The latter retains every canonical projection because sharing one RPC is valid and intentional.
type InterfaceRegistryEntry ¶ added in v1.0.52
type InterfaceRegistryEntry struct {
CanonicalPath string
Ref InterfaceRefSpec
Metadata embeddedMCPToolMetadata
}
InterfaceRegistryEntry is one operation projection from the fixed embedded MCP metadata. CanonicalPath is a metadata lookup key, not command identity.
type InterfaceSpec ¶ added in v1.0.52
type InterfaceSpec struct {
Ref *InterfaceRefSpec
Mode string
Availability string
Reason string
}
InterfaceSpec describes whether and how the Agent may invoke the backing interface.
func (InterfaceSpec) AgentExecutable ¶ added in v1.0.52
func (i InterfaceSpec) AgentExecutable() bool
AgentExecutable reports whether the final contract permits an Agent to invoke this command. Interface mode describes the implementation mechanism; availability is the independent execution gate.
func (InterfaceSpec) Validate ¶ added in v1.0.52
func (i InterfaceSpec) Validate(canonical string) error
Validate enforces the final interface-disposition conflict matrix. It does not prove that an MCP ref exists in the pinned interface registry; that exact lookup is performed by validateSchemaRegistryInterfaces.
type ManualAgentExampleDisposition ¶ added in v1.0.52
type ManualAgentExampleDisposition struct {
Index *int `json:"index"`
Mode ManualAgentExampleMode `json:"mode"`
ReasonCode ManualAgentExampleReasonCode `json:"reason_code"`
Reason string `json:"reason"`
Reviewed bool `json:"reviewed"`
}
ManualAgentExampleDisposition narrows one exact example with an explicit typed dry-run capability to contract-only. Index is a pointer so a missing JSON field cannot silently select example zero.
type ManualAgentExampleDispositionSource ¶ added in v1.0.52
type ManualAgentExampleDispositionSource string
ManualAgentExampleDispositionSource distinguishes the normal typed-contract classification from narrow reviewed manual exceptions.
const ( ManualAgentExampleDispositionDefault ManualAgentExampleDispositionSource = "default" ManualAgentExampleDispositionReviewedManual ManualAgentExampleDispositionSource = "reviewed_manual" )
type ManualAgentExampleExecution ¶ added in v1.0.52
type ManualAgentExampleExecution struct {
CanonicalPath string
Index int
Example string
Mode ManualAgentExampleMode
DryRun *DryRunSpec
ReasonCode ManualAgentExampleReasonCode
Reason string
Source ManualAgentExampleDispositionSource
}
ManualAgentExampleExecution is one resolved example and its effective test mode. Contract validation has already succeeded when this value is returned.
type ManualAgentExampleExecutionPlan ¶ added in v1.0.52
type ManualAgentExampleExecutionPlan struct {
Examples []ManualAgentExampleExecution
Total int
Contract int
DryRun int
ContractOnly int
ReviewedContractOnly int
ContractOnlyByReason map[ManualAgentExampleReasonCode]int
}
ManualAgentExampleExecutionPlan is a stable, typed report used by the exhaustive real-Cobra dry-run test. Counts are derived only from the final typed dry-run capability and committed reviewed dispositions; runtime failures can never add implicit skips.
func BuildManualAgentExampleExecutionPlan ¶ added in v1.0.52
func BuildManualAgentExampleExecutionPlan(bound BoundCommandRegistry, registry SchemaRegistry, hints ManualAgentHintSet) (ManualAgentExampleExecutionPlan, error)
BuildManualAgentExampleExecutionPlan validates every example against its real BoundCommand/Cobra contract. Runtime dry-run execution is opt-in and comes only from the final typed ToolSpec; a globally accepted --dry-run flag is not capability evidence. Only unavoidable local-state or stateful- preflight requirements may narrow an explicit capability through an exact reviewed manual disposition. Callers must never turn a runtime failure into an implicit skip.
func ValidateEmbeddedManualAgentExampleDelivery ¶ added in v1.0.52
func ValidateEmbeddedManualAgentExampleDelivery(bound BoundCommandRegistry, registry SchemaRegistry) (ManualAgentExampleExecutionPlan, error)
ValidateEmbeddedManualAgentExampleDelivery is the final generation gate. It validates the committed Manual Agent hints against the fully assembled typed SchemaRegistry, after generated Agent metadata has been compiled in. This is deliberately stronger than the pre-generation path/flag validation above.
type ManualAgentExampleMode ¶ added in v1.0.52
type ManualAgentExampleMode string
ManualAgentExampleMode controls only how an already contract-validated example is exercised. Contract validation is the default. dry_run is used only when the final ToolSpec publishes an explicit reviewed capability; contract_only remains a precise reviewed exception for such a capability whose runtime preconditions cannot be exercised safely and deterministically in the isolated test process.
const ( ManualAgentExampleModeContract ManualAgentExampleMode = "contract" ManualAgentExampleModeDryRun ManualAgentExampleMode = "dry_run" ManualAgentExampleModeContractOnly ManualAgentExampleMode = "contract_only" )
type ManualAgentExampleReasonCode ¶ added in v1.0.52
type ManualAgentExampleReasonCode string
ManualAgentExampleReasonCode is a closed taxonomy for reviewed contract-only exceptions to an explicit dry-run capability. Safety and confirmation remain independently enforced and cannot be weakened through an example disposition. There is deliberately no generic "skip" value: a reviewer must identify the concrete precondition.
const ( ManualAgentExampleReasonLocalState ManualAgentExampleReasonCode = "local_state" ManualAgentExampleReasonStatefulPreflight ManualAgentExampleReasonCode = "stateful_preflight" )
type ManualAgentHintRevision ¶ added in v1.0.52
type ManualAgentHintRevision struct {
GeneratedBy string `json:"generated_by"`
Model string `json:"model,omitempty"`
PromptVersion string `json:"prompt_version,omitempty"`
Reason string `json:"reason"`
}
ManualAgentHintRevision records how one reviewed authoring batch was produced. Product and tool entries reference it by the enclosing map key so later focused revisions do not relabel unchanged prose.
type ManualAgentHintSet ¶ added in v1.0.52
type ManualAgentHintSet struct {
Revisions map[string]ManualAgentHintRevision `json:"revisions,omitempty"`
Products map[string]ManualAgentProductHint `json:"products,omitempty"`
Tools map[string]ManualAgentToolHint `json:"tools,omitempty"`
}
ManualAgentHintSet keeps reviewed Agent-selection prose in the same manual source as command and parameter overrides without making that prose an identity annotation. Generators may read this section; they must never write it back or use it to change executable, parameter, safety, or interface facts.
func LoadAgentHintsFromSelectionForValidation ¶ added in v1.0.52
func LoadAgentHintsFromSelectionForValidation(selectionFS fs.FS) (ManualAgentHintSet, error)
LoadAgentHintsFromSelectionForValidation loads selection HintFiles from an FS rooted at schema_hints/selection (so glob *.json).
type ManualAgentProductHint ¶ added in v1.0.52
type ManualAgentProductHint struct {
AgentSummary string `json:"agent_summary"`
UseWhen []string `json:"use_when"`
AvoidWhen []string `json:"avoid_when"`
Reviewed bool `json:"reviewed"`
Revision string `json:"revision"`
Reason string `json:"reason"`
Evidence []string `json:"evidence"`
}
ManualAgentProductHint defines product-level routing prose.
type ManualAgentSelectionCase ¶ added in v1.0.52
type ManualAgentSelectionCase struct {
ID string `json:"id"`
ProductID string `json:"product_id"`
Scenario string `json:"scenario"`
ExpectedCanonical string `json:"expected_canonical,omitempty"`
ForbiddenCanonical string `json:"forbidden_canonical,omitempty"`
CandidateCanonicals []string `json:"candidate_canonicals"`
}
ManualAgentSelectionCase is one reproducible model-evaluation assertion derived from reviewed Manual Agent hints. Positive cases require one exact canonical result; negative cases only forbid the command that owns the avoid_when text. CandidateCanonicals contains every bound tool in the same product, in stable order.
type ManualAgentSelectionFixture ¶ added in v1.0.52
type ManualAgentSelectionFixture struct {
Version int `json:"version"`
Cases []ManualAgentSelectionCase `json:"cases"`
}
ManualAgentSelectionFixture is the stable input to an optional live Agent evaluation. It is built from schema_hints/selection and the real bound command tree; it is not a second authored hint source.
type ManualAgentSelectionReport ¶ added in v1.0.52
type ManualAgentSelectionReport struct {
Tools int
PositiveAssertions int
NegativeAssertions int
FixtureSHA256 string
}
ManualAgentSelectionReport records deterministic coverage and the exact fixture digest. It proves that all reviewed assertions are well-formed and executable; it deliberately does not claim that a language model understood their natural-language meaning.
func ValidateManualAgentSelectionContract ¶ added in v1.0.52
func ValidateManualAgentSelectionContract(bound BoundCommandRegistry, hints ManualAgentHintSet) (ManualAgentSelectionReport, error)
ValidateManualAgentSelectionContract is the lightweight generator-facing gate. Callers that run a semantic model evaluation should use BuildManualAgentSelectionEvalFixture and pass the returned cases to it.
type ManualAgentToolHint ¶ added in v1.0.52
type ManualAgentToolHint struct {
AgentSummary string `json:"agent_summary"`
UseWhen []string `json:"use_when"`
AvoidWhen []string `json:"avoid_when"`
Examples []string `json:"examples"`
ExampleDispositions []ManualAgentExampleDisposition `json:"example_dispositions,omitempty"`
Reviewed bool `json:"reviewed"`
Revision string `json:"revision"`
Reason string `json:"reason"`
Evidence []string `json:"evidence"`
}
ManualAgentToolHint defines the reviewed prose used to select and demonstrate one existing effective command. ExampleDispositions contains only test eligibility exceptions; it cannot change identity, parameters, safety, or interface disposition.
type ManualSchemaCommandHint ¶ added in v1.0.52
type ManualSchemaCommandHint struct {
CLIPath string `json:"cli_path"`
CanonicalPath string `json:"canonical_path"`
Reason string `json:"reason"`
Reviewed bool `json:"reviewed"`
Parameters map[string]ManualSchemaParameterHint `json:"parameters,omitempty"`
}
ManualSchemaCommandHint opts one exact existing Cobra leaf into Schema and optionally reviews its CLI-facing parameter projection.
type ManualSchemaHintReport ¶ added in v1.0.52
ManualSchemaHintReport records the exact reviewed inputs applied to a command tree. It is useful to generators and tests; no runtime discovery is performed.
func ApplyEmbeddedManualSchemaHints ¶ added in v1.0.52
func ApplyEmbeddedManualSchemaHints(root *cobra.Command) (ManualSchemaHintReport, error)
ApplyEmbeddedManualSchemaHints applies the committed human review file to an already-built Cobra tree. The operation is deterministic and idempotent.
type ManualSchemaHintSnapshot ¶ added in v1.0.52
type ManualSchemaHintSnapshot struct {
Schema string `json:"$schema"`
Version int `json:"version"`
Commands []ManualSchemaCommandHint `json:"commands"`
AgentHints ManualAgentHintSet `json:"agent_hints"`
}
ManualSchemaHintSnapshot is the human-owned bridge from an existing public Cobra leaf to Schema. It cannot create commands, flags, exclusions, or interfaces: every referenced command and flag is checked against the live tree before any annotation is applied.
func DecodeManualSchemaHintSource ¶ added in v1.0.52
func DecodeManualSchemaHintSource(data []byte) (ManualSchemaHintSnapshot, error)
DecodeManualSchemaHintSource strictly decodes the reviewed manual input for build-time generators and policy checks. Callers receive data only; this function never writes or normalizes the source file in place.
type ManualSchemaParameterHint ¶ added in v1.0.52
type ManualSchemaParameterHint struct {
Description *string `json:"description,omitempty"`
Property *string `json:"property,omitempty"`
InterfaceType *string `json:"interface_type,omitempty"`
Required *bool `json:"required,omitempty"`
RequiredWhen *string `json:"required_when,omitempty"`
}
ManualSchemaParameterHint changes only Schema annotations on a real flag. Pointer fields distinguish an omitted override from an explicit false.
type ParameterSchemaHint ¶ added in v1.0.52
type ParameterSchemaHint struct {
FlagName string
Type string
Description string
Required *bool
RequiredWhen string
}
ParameterSchemaHint overrides the projected flat schema for one parameter. It can be keyed either by the original MCP parameter name (preferred) or by the final CLI flag name when a hint is purely CLI-facing.
type ParameterSpec ¶ added in v1.0.52
type ParameterSpec struct {
Name string
Type string
Description string
Property string
Required bool
CLIRequired bool
RequiredWhen string
Default json.RawMessage
InterfaceDefault json.RawMessage
Example json.RawMessage
Format string
Enum []string
InterfaceDescription string
InterfaceType string
FieldProvenance map[string]FieldProvenance
Extensions map[string]json.RawMessage
}
ParameterSpec is one resolved CLI flag projection. Name is the CLI flag key used in the legacy parameters object. Default and Example are RawMessage because JSON literals are polymorphic; they are still typed JSON values and never participate in precedence as map[string]any.
type ProductSpec ¶ added in v1.0.52
type ProductSpec struct {
ID string
Name string
Description string
Runtime bool
Tools []ToolSpec
Selection SelectionSpec
FieldProvenance map[string]FieldProvenance
Extensions map[string]json.RawMessage
}
ProductSpec is one deterministic product grouping in SchemaRegistry.
func (ProductSpec) ToPayload ¶ added in v1.0.52
func (p ProductSpec) ToPayload() (map[string]any, error)
ToPayload renders one product and its full tools.
func (ProductSpec) ToSummaryPayload ¶ added in v1.0.52
func (p ProductSpec) ToSummaryPayload() (map[string]any, error)
ToSummaryPayload renders one product with progressive tool summaries. Both this view and the full product payload are projections of the same ToolSpec slice; neither re-resolves annotations or metadata.
type ResolvedSchemaBuild ¶ added in v1.0.52
type ResolvedSchemaBuild struct {
// contains filtered or unexported fields
}
ResolvedSchemaBuild is the single source-to-delivery hand-off used by the Catalog generator. Effective, Bound, and Registry are three views of one resolution pass: reviewed identity, executable Cobra binding, and the final typed Agent contract. Downstream gates and serializers must consume this value instead of rebuilding any view from the command tree.
The command root is intentionally private. It lets delivery completeness inspect the same executable tree without allowing callers to construct a seemingly resolved build by assembling the exported fields themselves.
func ResolveSchemaBuild ¶ added in v1.0.52
func ResolveSchemaBuild(root *cobra.Command) (ResolvedSchemaBuild, error)
ResolveSchemaBuild is the only assembly path from executable Cobra commands and reviewed metadata into the typed Agent contract. It applies reviewed manual annotations once, resolves identity once, binds Cobra once, and assembles one SchemaRegistry. Catalog gates and serialization consume the returned value directly; they never re-read annotations or merge sources.
func (ResolvedSchemaBuild) CommandCount ¶ added in v1.0.52
func (resolved ResolvedSchemaBuild) CommandCount() int
CommandCount reports the reviewed effective command count for generator diagnostics without exposing a mutable registry view.
func (ResolvedSchemaBuild) RegistryHash ¶ added in v1.0.52
func (resolved ResolvedSchemaBuild) RegistryHash() string
RegistryHash returns the semantic identity/navigation hash attached to this resolved build. It is an envelope value, not a second registry input.
type RuntimeCompatibilityEquivalence ¶ added in v1.0.52
type RuntimeCompatibilityEquivalence struct {
ID string `json:"id"`
Reason string `json:"reason"`
Reviewed bool `json:"reviewed"`
}
RuntimeCompatibilityEquivalence is an implementation-side review record for two separately registered Cobra leaves that intentionally share one Schema identity despite using different execution handlers. Registry alias review alone is not enough: different handlers may inject fixed arguments or route to different business operations while exposing identical flags.
type RuntimeSchemaCompletenessReport ¶ added in v1.0.52
type RuntimeSchemaCompletenessReport struct {
Covered []string
Excluded []string
Missing []string
InvalidExclusions []string
StaleExclusions []string
DeliveryErrors []string
}
RuntimeSchemaCompletenessReport compares the public executable Cobra leaves with a reviewed Schema command set, such as runtime annotations or the final generated Catalog.
func RuntimeSchemaCompleteness ¶ added in v1.0.52
func RuntimeSchemaCompleteness(root *cobra.Command, exclusions []RuntimeSchemaExclusion) RuntimeSchemaCompletenessReport
RuntimeSchemaCompleteness scans the real command tree in the reverse direction: every public executable leaf must either belong to the effective reviewed CommandRegistry or have a reviewed exclusion with a non-empty reason.
type RuntimeSchemaConstraints ¶ added in v1.0.52
type RuntimeSchemaConstraints struct {
MutuallyExclusive [][]string `json:"mutually_exclusive,omitempty"`
RequireOneOf [][]string `json:"require_one_of,omitempty"`
RequireTogether [][]string `json:"require_together,omitempty"`
}
RuntimeSchemaConstraints describes cross-parameter rules that cannot be represented by an individual parameter's required bit.
type RuntimeSchemaExclusion ¶ added in v1.0.52
type RuntimeSchemaExclusion struct {
CLIPath string `json:"cli_path"`
Reason string `json:"reason"`
Reviewed bool `json:"reviewed"`
}
RuntimeSchemaExclusion records a reviewed reason why a public executable command is intentionally not advertised as an Agent tool.
func EmbeddedRuntimeSchemaExclusions ¶ added in v1.0.52
func EmbeddedRuntimeSchemaExclusions() ([]RuntimeSchemaExclusion, error)
EmbeddedRuntimeSchemaExclusions returns the exact, reviewed list of public CLI leaves intentionally kept outside the stable Agent command contract.
type RuntimeSchemaParameterMetadata ¶ added in v1.0.52
type RuntimeSchemaParameterMetadata struct {
Inherited []string
Required []string
RequiredWhen map[string]string
Formats map[string]string
Enums map[string][]string
Examples map[string]string
}
RuntimeSchemaParameterMetadata contains reviewed CLI parameter semantics that Cobra cannot represent by itself. It is an independent generation input: generated Catalog data is never read back into this registry.
type RuntimeSchemaPositional ¶ added in v1.0.52
type RuntimeSchemaPositional struct {
Name string `json:"name"`
Type string `json:"type,omitempty"`
Description string `json:"description,omitempty"`
Required bool `json:"required"`
Variadic bool `json:"variadic,omitempty"`
Index int `json:"index"`
}
RuntimeSchemaPositional describes one ordered CLI argument. Name is also used by RuntimeSchemaConstraints when a one-of group mixes flags and args.
type RuntimeToolSpecInput ¶ added in v1.0.52
type RuntimeToolSpecInput struct {
Identity ToolIdentitySpec
Display string
Title string
Description string
MetadataSource string
Parameters []ParameterSpec
Constraints RuntimeSchemaConstraints
Positionals []RuntimeSchemaPositional
DryRun *DryRunSpec
Safety SafetySpec
Interface InterfaceSpec
Selection SelectionSpec
FieldProvenance map[string]FieldProvenance
Extensions map[string]json.RawMessage
}
RuntimeToolSpecInput is the typed hand-off from runtime source resolution to contract assembly. Adapters resolve candidates first, then call ToolSpecFromRuntime exactly once; payload rendering does no further merging.
type SafetySpec ¶ added in v1.0.52
type SafetySpec struct {
Effect string
EffectSource string
Risk string
Confirmation string
Idempotency string
}
SafetySpec is the resolved operation behavior. This model deliberately does not impose a value lattice: precedence policy belongs to the resolver, so a reviewed higher-priority source may intentionally raise or lower a value.
type SchemaCatalogBuildOptions ¶ added in v1.0.52
type SchemaCatalogBuildOptions struct {
RegistryHash string
}
SchemaCatalogBuildOptions carries release-envelope inputs which are checked against the effective reviewed CommandRegistry. The command set is not an option: visibility is resolved by EffectiveCommandRegistry before assembly, and every public command must be delivered.
type SchemaCatalogSnapshot ¶ added in v1.0.52
type SchemaCatalogSnapshot struct {
Version int `json:"version"`
SourceHash string `json:"source_hash"`
SurfaceHash string `json:"surface_hash,omitempty"`
Catalog map[string]any `json:"catalog"`
Tools map[string]map[string]any `json:"tools"`
}
SchemaCatalogSnapshot is the release-stable Agent contract. Catalog holds the progressive product/tool index; Tools holds full leaf parameter schemas. It intentionally contains no endpoint, credential, or runtime cache data.
func BuildSchemaCatalogSnapshot ¶ added in v1.0.52
func BuildSchemaCatalogSnapshot(resolved ResolvedSchemaBuild, options SchemaCatalogBuildOptions) (SchemaCatalogSnapshot, error)
BuildSchemaCatalogSnapshot renders a deterministic Catalog from one resolved source-to-delivery hand-off. It deliberately accepts no Cobra root: reapplying manual hints or rebuilding SchemaRegistry at this boundary would allow generation gates to validate one candidate while publishing another.
type SchemaHintRegistry ¶ added in v1.0.52
type SchemaHintRegistry struct {
// contains filtered or unexported fields
}
func (*SchemaHintRegistry) Lookup ¶ added in v1.0.52
func (r *SchemaHintRegistry) Lookup(canonicalPath string) (ToolSchemaHint, bool)
func (*SchemaHintRegistry) RegisterProduct ¶ added in v1.0.52
func (r *SchemaHintRegistry) RegisterProduct(productID string, tools map[string]ToolSchemaHint)
type SchemaIndex ¶ added in v1.0.52
type SchemaIndex struct {
// contains filtered or unexported fields
}
SchemaIndex is the immutable navigation view over one normalized registry. It mirrors Lark's typed catalog split: SchemaRegistry owns data, SchemaIndex owns deterministic identity/path resolution, and serializers only render a resolved ToolSpec.
func (SchemaIndex) CanonicalPaths ¶ added in v1.0.52
func (i SchemaIndex) CanonicalPaths() []string
CanonicalPaths returns the complete tool identity set in stable order.
func (SchemaIndex) Product ¶ added in v1.0.52
func (i SchemaIndex) Product(id string) (ProductSpec, bool)
Product resolves one product by exact stable ID.
func (SchemaIndex) Registry ¶ added in v1.0.52
func (i SchemaIndex) Registry() SchemaRegistry
Registry returns the detached normalized registry owned by this index.
func (SchemaIndex) Resolve ¶ added in v1.0.52
func (i SchemaIndex) Resolve(path string) (ToolSpec, bool)
Resolve resolves either an exact canonical path or a normalized CLI path. No inference or fuzzy matching occurs in this layer.
func (SchemaIndex) ResolveQuery ¶ added in v1.0.54
func (i SchemaIndex) ResolveQuery(path string) (ToolSpec, bool)
ResolveQuery adds compatibility for dotted and slash-separated CLI paths at the user-facing query boundary. Resolve remains strict because Registry validation uses it to detect missing canonical identities without falling through to a similarly spelled CLI path.
type SchemaMetadataLoadCounts ¶ added in v1.0.52
type SchemaMetadataLoadCounts struct {
Catalog uint64
AgentMetadata uint64
MCPMetadata uint64
ParameterBinding uint64
}
SchemaMetadataLoadCounts exposes read-only diagnostics for startup tests and profiling. Counts are incremented only when a lazy embedded snapshot is parsed for the first time.
func RuntimeSchemaMetadataLoadCounts ¶ added in v1.0.52
func RuntimeSchemaMetadataLoadCounts() SchemaMetadataLoadCounts
RuntimeSchemaMetadataLoadCounts reads the concurrency-safe lazy loader counters without triggering any loader.
type SchemaRegistry ¶ added in v1.0.52
type SchemaRegistry struct {
Kind string
Level string
Source string
Products []ProductSpec
InterfaceMetadata json.RawMessage
AgentMetadata json.RawMessage
Extensions map[string]json.RawMessage
}
SchemaRegistry is the resolved, typed Agent contract. Source adapters and precedence resolvers populate this model; wire payloads are rendered only at the outer boundary by ToPayload. This keeps map[string]any out of the contract assembly path.
func AssembleSchemaRegistry ¶ added in v1.0.52
func AssembleSchemaRegistry(root *cobra.Command) (SchemaRegistry, error)
AssembleSchemaRegistry is retained for non-Catalog callers that only need the typed registry. Catalog production must use ResolveSchemaBuild so the bound/effective views remain attached to the exact same resolution pass.
func AssembleSchemaRegistryFromBound ¶ added in v1.0.52
func AssembleSchemaRegistryFromBound(bound BoundCommandRegistry) (SchemaRegistry, error)
AssembleSchemaRegistryFromBound resolves non-identity sources into the single typed ToolSpec model. Command discovery is intentionally impossible below this boundary: callers must first provide a fail-closed bound registry.
func SchemaRegistryFromRuntime ¶ added in v1.0.52
func SchemaRegistryFromRuntime(source string, products []ProductSpec) (SchemaRegistry, error)
SchemaRegistryFromRuntime constructs and validates the one registry shared by leaf lookup, Catalog summaries and full export.
func (SchemaRegistry) Index ¶ added in v1.0.52
func (r SchemaRegistry) Index() (SchemaIndex, error)
Index validates all registry identities and returns deterministic navigation indexes. Canonical paths, primary CLI paths and reviewed aliases must each resolve unambiguously.
func (SchemaRegistry) Sorted ¶ added in v1.0.52
func (r SchemaRegistry) Sorted() SchemaRegistry
Sorted returns a detached, deterministic registry. Products are ordered by ID, tools by canonical path then CLI path, and parameters by CLI flag name.
func (SchemaRegistry) ToOverviewPayload ¶ added in v1.0.52
func (r SchemaRegistry) ToOverviewPayload() (map[string]any, error)
ToOverviewPayload renders the small first-hop product index directly from the resolved registry. It is a presentation projection only: it never reads Agent metadata or any other source after assembly.
func (SchemaRegistry) ToPayload ¶ added in v1.0.52
func (r SchemaRegistry) ToPayload() (map[string]any, error)
ToPayload renders the compatible flat schema payload after deterministically sorting the typed model.
func (SchemaRegistry) ToSnapshotPayload ¶ added in v1.0.52
func (r SchemaRegistry) ToSnapshotPayload() (SchemaSnapshotPayload, error)
ToSnapshotPayload derives the progressive Catalog and full tool map from one normalized registry. This is the direct typed replacement for separately assembling runtimeToolSummary and runtimeToolPayload.
type SchemaSnapshotPayload ¶ added in v1.0.52
SchemaSnapshotPayload is the final wire boundary for the release snapshot. Catalog summaries and full Tools are both derived from the same typed ToolSpec instances, preventing the two snapshot layers from drifting.
type SchemaVisibility ¶ added in v1.0.52
type SchemaVisibility string
const ( SchemaVisibilityPublic SchemaVisibility = "public" SchemaVisibilityCompat SchemaVisibility = "compat" SchemaVisibilityInternal SchemaVisibility = "internal" )
type SelectionSpec ¶ added in v1.0.52
type SelectionSpec struct {
AgentSummary string
AgentSummarySource string
UseWhen []string
AvoidWhen []string
Prerequisites []string
Tips []string
WorkflowRefs []string
Examples []string
Reviewed *bool
SourceRefs []string
MetadataSource string
}
SelectionSpec contains Agent command-selection guidance. Product specs use the common summary/use/avoid/source subset; tool specs may use every field.
type StaticLoader ¶
type StaticLoader struct {
Catalog Catalog
}
StaticLoader returns a pre-built catalog.
type StdinGuard ¶
type StdinGuard struct {
// contains filtered or unexported fields
}
StdinGuard ensures stdin is consumed at most once per command invocation. Multiple flags using @- or implicit stdin fallback would race on the same reader; StdinGuard detects and rejects the second claim with a clear error.
func NewStdinGuard ¶
func NewStdinGuard() *StdinGuard
NewStdinGuard creates a fresh guard for one command invocation.
func (*StdinGuard) Claim ¶
func (g *StdinGuard) Claim(source string) error
Claim marks stdin as consumed by the named source (e.g. "--text @-"). Returns an error if stdin was already claimed.
func (*StdinGuard) Claimed ¶
func (g *StdinGuard) Claimed() bool
Claimed reports whether stdin has been consumed.
type ToolDescriptor ¶ added in v1.0.48
type ToolDescriptor struct {
RPCName string `json:"rpc_name"`
CanonicalPath string `json:"canonical_path"`
}
ToolDescriptor represents a single tool in a canonical product.
type ToolIdentitySpec ¶ added in v1.0.52
type ToolIdentitySpec struct {
ProductID string
SourceProductID string
Name string
CLIName string
CanonicalPath string
Path string
CLIPath string
PrimaryCLIPath string
Group string
Aliases []string
IsAlias bool
Source string
}
ToolIdentitySpec contains only command identity. It is intentionally separate from interface identity: an executable Cobra leaf and an RPC are related by InterfaceSpec, but are not interchangeable sources of truth.
type ToolSchemaHint ¶ added in v1.0.52
type ToolSchemaHint struct {
Title string
Description string
Parameters map[string]ParameterSchemaHint
}
ToolSchemaHint is reviewed field metadata for an existing registry-owned tool. It intentionally has no command path, alias, visibility, or canonical identity fields: all identity/navigation comes from CommandRegistry.
type ToolSpec ¶ added in v1.0.52
type ToolSpec struct {
Identity ToolIdentitySpec
Display string
Title string
Description string
MetadataSource string
Parameters []ParameterSpec
Constraints RuntimeSchemaConstraints
Positionals []RuntimeSchemaPositional
DryRun *DryRunSpec
Safety SafetySpec
Interface InterfaceSpec
Selection SelectionSpec
FieldProvenance map[string]FieldProvenance
Extensions map[string]json.RawMessage
}
ToolSpec is the single assembled representation of a command contract. Safety, interface and selection are typed sub-models even though ToPayload preserves the historical flat JSON shape for compatibility.
func ToolSpecFromRuntime ¶ added in v1.0.52
func ToolSpecFromRuntime(input RuntimeToolSpecInput) (ToolSpec, error)
ToolSpecFromRuntime validates and normalizes the fully resolved runtime input. It does not choose between sources; that is the resolver's job.
func (ToolSpec) ToPayload ¶ added in v1.0.52
ToPayload renders one full leaf contract in the existing flat JSON shape.
func (ToolSpec) ToSummaryPayload ¶ added in v1.0.52
ToSummaryPayload projects a ToolSpec without parameters and leaf-only execution detail. It is derived from the same typed ToolSpec, never assembled independently.
Source Files
¶
- canonical.go
- loader.go
- priority.go
- runtime_schema.go
- schema_agent_metadata.go
- schema_agent_selection.go
- schema_catalog.go
- schema_cobra_binding.go
- schema_command_registry.go
- schema_completeness.go
- schema_constraints_runtime.go
- schema_contract_model.go
- schema_delivery_invariants.go
- schema_dry_run_capabilities.go
- schema_hint_dirs.go
- schema_hints.go
- schema_hints_aitable.go
- schema_hints_attendance.go
- schema_hints_ding.go
- schema_hints_helper_roots.go
- schema_hints_runtime.go
- schema_identity_resolver.go
- schema_interface_registry.go
- schema_lazy_metadata.go
- schema_manual_hints.go
- schema_parameter_bindings.go
- schema_parameters_runtime.go
- schema_runtime_registry.go
- schema_snapshot_adapter.go
- schema_support.go
- schema_validate.go
- stdin.go