Documentation
¶
Index ¶
- Constants
- func NewMCPCommand(ctx context.Context, loader CatalogLoader, runner executor.Runner, ...) *cobra.Command
- func NewSchemaCommand(loader CatalogLoader) *cobra.Command
- func OverridePriority(cmd *cobra.Command) int
- func ReadFileArg(value string) (string, bool, error)
- func ReadStdin() (string, error)
- func ReadStdinIfPiped() (string, error)
- func ResolveInputSource(value string, flagName string, guard *StdinGuard) (string, error)
- func SetOverridePriority(cmd *cobra.Command, priority int)
- func StdinIsPipe() bool
- func ValidateInputSchema(params map[string]any, schema map[string]any) error
- type CatalogDegraded
- type CatalogDegradedReason
- type CatalogLoader
- type EnvironmentLoader
- type FixtureLoader
- type FlagKind
- type FlagSpec
- type StaticLoader
- type StdinGuard
Constants ¶
const ( CatalogFixtureEnv = "DWS_CATALOG_FIXTURE" CacheDirEnv = "DWS_CACHE_DIR" PluginColdTimeoutEnv = "DWS_PLUGIN_COLD_TIMEOUT" DefaultMarketBaseURL = "https://mcp.dingtalk.com" )
Variables ¶
This section is empty.
Functions ¶
func NewMCPCommand ¶
func NewSchemaCommand ¶
func NewSchemaCommand(loader CatalogLoader) *cobra.Command
func OverridePriority ¶
OverridePriority delegates to cobracmd.OverridePriority.
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 "@". 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 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 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.
Types ¶
type CatalogDegraded ¶ added in v1.0.9
type CatalogDegraded struct {
Reason CatalogDegradedReason
Hint string
ServerCount int // number of servers discovered (only set for runtime_all_failed)
}
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 ¶
func CatalogLoaderFrom ¶
func CatalogLoaderFrom(catalog ir.Catalog, err error) CatalogLoader
CatalogLoaderFrom creates a CatalogLoader that returns a pre-loaded catalog and error. This allows multiple consumers (schema command, MCP command tree) to share one discovery result.
type EnvironmentLoader ¶
type EnvironmentLoader struct {
LookupEnv func(string) (string, bool)
// CatalogBaseURLOverride allows tests to redirect catalog discovery.
CatalogBaseURLOverride string
// DiscoveryTimeout overrides the default timeout for live registry discovery.
// Zero means use defaultDiscoveryTimeout.
DiscoveryTimeout time.Duration
// AuthTokenFunc returns an access token for MCP discovery requests
// (initialize, tools/list). When nil, discovery runs without auth.
AuthTokenFunc func(context.Context) string
// LoggerFunc returns a structured logger for discovery diagnostics.
// Called lazily because the file logger may not be initialized at
// construction time (it's set up during PersistentPreRunE).
LoggerFunc func() *slog.Logger
}
func NewEnvironmentLoader ¶
func NewEnvironmentLoader() EnvironmentLoader
type FixtureLoader ¶
type FixtureLoader struct {
Path string
}
type FlagSpec ¶
type FlagSpec struct {
PropertyName string
FlagName string
Alias string
Shorthand string
Kind FlagKind
Description string
}
func BuildFlagSpecs ¶
type StaticLoader ¶
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.