Wire native PromptKit sources into CLI commands
This commit is contained in:
@@ -218,7 +218,16 @@ outside the deliberate field removals.
|
||||
|
||||
## Stage 3: Wire Native Sources Through All Existing CLI Engine Paths
|
||||
|
||||
Status: Pending. Depends on Stage 2.
|
||||
Status: Complete. Existing CLI engine paths now use the ordered native source
|
||||
selectors, explicit repeated source flags, ConfigKit file inputs and PromptKit
|
||||
directory inputs; profile/prompt inspection shares the same captured sources.
|
||||
Retired directory/backend wiring and the empty-prompt filesystem are removed,
|
||||
and captured diagnostics use the existing safe writer. `go build -o
|
||||
/tmp/scriptorium-promptkit-native ./cmd/scriptorium`, `go test
|
||||
./internal/config`, `gofmt`, and `git diff --check` pass. Full test/race/vet
|
||||
checks reach only the stale CLI fields/fixtures assigned to Stages 5–6 and
|
||||
removed PromptKit test constructors assigned to Stage 7; those are not
|
||||
migrated here.
|
||||
|
||||
Files: `internal/adapter/cli/application_config.go`, `run.go`, `inspect.go`,
|
||||
`config.go`; add a small `framework_sources.go` if useful within this package.
|
||||
|
||||
@@ -16,10 +16,8 @@ func applicationOverrides(fs *flag.FlagSet) []configkit.Override {
|
||||
fs.Visit(func(selected *flag.Flag) {
|
||||
var path configkit.Path
|
||||
switch selected.Name {
|
||||
case "prompt-dir":
|
||||
path = configkit.Keys("prompt_dir")
|
||||
case "profile-dir":
|
||||
path = configkit.Keys("profile_dir")
|
||||
case "promptkit-source":
|
||||
path = configkit.Keys("promptkit_sources")
|
||||
case "schema-dir":
|
||||
path = configkit.Keys("schema_dir")
|
||||
case "addr":
|
||||
|
||||
@@ -93,8 +93,6 @@ func configCommand(args []string, stdout, stderr io.Writer) int {
|
||||
}
|
||||
|
||||
func registerConfigurationOverrides(fs *flag.FlagSet) {
|
||||
fs.String("prompt-dir", "", "prompt-definition directory override")
|
||||
fs.String("profile-dir", "", "profile directory override")
|
||||
fs.String("schema-dir", "", "schema directory override")
|
||||
fs.String("addr", "", "HTTP listen address override")
|
||||
fs.String("artifact-root", "", "HTTP artifact root override")
|
||||
|
||||
74
internal/adapter/cli/framework_sources.go
Normal file
74
internal/adapter/cli/framework_sources.go
Normal file
@@ -0,0 +1,74 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"gitea.maximumdirect.net/eric/promptkit"
|
||||
)
|
||||
|
||||
type promptKitSourceFlagEntry struct {
|
||||
selector string
|
||||
path string
|
||||
}
|
||||
|
||||
// promptKitSourceFlagValue treats each occurrence as one selected source path.
|
||||
type promptKitSourceFlagValue struct {
|
||||
entries []promptKitSourceFlagEntry
|
||||
}
|
||||
|
||||
func (value *promptKitSourceFlagValue) Set(path string) error {
|
||||
trimmed := strings.TrimSpace(path)
|
||||
if trimmed == "" {
|
||||
return errors.New("--promptkit-source requires a nonblank path")
|
||||
}
|
||||
|
||||
info, err := os.Stat(filepath.Clean(trimmed))
|
||||
if err != nil {
|
||||
reason := "unavailable"
|
||||
if errors.Is(err, os.ErrPermission) {
|
||||
reason = "permission denied"
|
||||
}
|
||||
return fmt.Errorf("--promptkit-source %q: %s", path, reason)
|
||||
}
|
||||
|
||||
selector := ""
|
||||
switch {
|
||||
case info.IsDir():
|
||||
selector = "directory"
|
||||
case info.Mode().IsRegular():
|
||||
selector = "file"
|
||||
default:
|
||||
return fmt.Errorf("--promptkit-source %q must be a regular file or directory", path)
|
||||
}
|
||||
value.entries = append(value.entries, promptKitSourceFlagEntry{selector: selector, path: path})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (value *promptKitSourceFlagValue) Get() any {
|
||||
selections := make([]any, 0, len(value.entries))
|
||||
for _, entry := range value.entries {
|
||||
selections = append(selections, map[string]any{entry.selector: entry.path})
|
||||
}
|
||||
return selections
|
||||
}
|
||||
|
||||
func (value *promptKitSourceFlagValue) String() string {
|
||||
paths := make([]string, 0, len(value.entries))
|
||||
for _, entry := range value.entries {
|
||||
paths = append(paths, entry.path)
|
||||
}
|
||||
return fmt.Sprint(paths)
|
||||
}
|
||||
|
||||
func writeFrameworkDiagnostics(output io.Writer, engine *promptkit.Engine) error {
|
||||
view, err := engine.InspectConfiguration()
|
||||
if err != nil {
|
||||
return fmt.Errorf("inspect captured PromptKit diagnostics: %w", err)
|
||||
}
|
||||
return writeApplicationWarnings(output, view.Diagnostics())
|
||||
}
|
||||
@@ -6,17 +6,15 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
configkit "gitea.maximumdirect.net/eric/ConfigKit"
|
||||
"gitea.maximumdirect.net/eric/promptkit"
|
||||
appformat "gitea.maximumdirect.net/eric/scriptorium/internal/format"
|
||||
)
|
||||
|
||||
type promptInspectionConfig struct {
|
||||
configPath, promptDir, promptID, promptVersion, outputPath string
|
||||
configPath, promptID, promptVersion, schemaDir, outputPath string
|
||||
configOverlay string
|
||||
configExplicit bool
|
||||
outputFormat appformat.OutputFormat
|
||||
@@ -25,21 +23,12 @@ type promptInspectionConfig struct {
|
||||
}
|
||||
|
||||
type profileInspectionConfig struct {
|
||||
configPath, profileDir, profileID, outputPath string
|
||||
configOverlay string
|
||||
configExplicit bool
|
||||
outputFormat appformat.OutputFormat
|
||||
overrides []configkit.Override
|
||||
diagnostics []configkit.Diagnostic
|
||||
}
|
||||
|
||||
// emptyPromptDefinitionFS satisfies Promptkit's engine-level prompt-source
|
||||
// requirement without exposing the caller's working directory. Profile
|
||||
// inspection never reads this source.
|
||||
type emptyPromptDefinitionFS struct{}
|
||||
|
||||
func (emptyPromptDefinitionFS) Open(name string) (fs.File, error) {
|
||||
return nil, &fs.PathError{Op: "open", Path: name, Err: fs.ErrNotExist}
|
||||
configPath, profileID, schemaDir, outputPath string
|
||||
configOverlay string
|
||||
configExplicit bool
|
||||
outputFormat appformat.OutputFormat
|
||||
overrides []configkit.Override
|
||||
diagnostics []configkit.Diagnostic
|
||||
}
|
||||
|
||||
func inspectCommand(args []string, stdout, stderr io.Writer) int {
|
||||
@@ -69,7 +58,11 @@ func inspectCommand(args []string, stdout, stderr io.Writer) int {
|
||||
}
|
||||
engine, err := newEngine(settings)
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "engine error: %v\n", err)
|
||||
writeApplicationError(stderr, "engine", err)
|
||||
return ExitRuntimeError
|
||||
}
|
||||
if err := writeFrameworkDiagnostics(stderr, engine); err != nil {
|
||||
fmt.Fprintf(stderr, "engine diagnostic write error: %v\n", err)
|
||||
return ExitRuntimeError
|
||||
}
|
||||
inspection, err := engine.InspectPrompt(context.Background(), cfg.promptID, cfg.promptVersion)
|
||||
@@ -103,9 +96,13 @@ func inspectProfileCommand(args []string, stdout, stderr io.Writer) int {
|
||||
if err := writeApplicationWarnings(stderr, cfg.diagnostics); err != nil {
|
||||
return ExitRuntimeError
|
||||
}
|
||||
engine, err := newEngine(settings, promptkit.WithPromptFS(emptyPromptDefinitionFS{}, "."))
|
||||
engine, err := newEngine(settings)
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "engine error: %v\n", err)
|
||||
writeApplicationError(stderr, "engine", err)
|
||||
return ExitRuntimeError
|
||||
}
|
||||
if err := writeFrameworkDiagnostics(stderr, engine); err != nil {
|
||||
fmt.Fprintf(stderr, "engine diagnostic write error: %v\n", err)
|
||||
return ExitRuntimeError
|
||||
}
|
||||
inspection, err := engine.InspectProfile(context.Background(), cfg.profileID)
|
||||
@@ -130,7 +127,9 @@ func parseProfileInspectionArgs(args []string) (*profileInspectionConfig, error)
|
||||
fs := flag.NewFlagSet("inspect profile", flag.ContinueOnError)
|
||||
fs.SetOutput(io.Discard)
|
||||
registerConfigSelectionFlags(fs, &cfg.configPath, &cfg.configOverlay)
|
||||
fs.StringVar(&cfg.profileDir, "profile-dir", "", "directory containing execution profiles")
|
||||
var promptkitSources promptKitSourceFlagValue
|
||||
fs.Var(&promptkitSources, "promptkit-source", "selected PromptKit source path (repeatable)")
|
||||
fs.StringVar(&cfg.schemaDir, "schema-dir", "", "base directory for validation schemas")
|
||||
fs.StringVar(&cfg.profileID, "profile", "", "profile ID to inspect")
|
||||
rawFormat := ""
|
||||
fs.StringVar(&rawFormat, "format", "", "output format: text or json")
|
||||
@@ -163,7 +162,7 @@ func resolveAppSettingsForProfileInspection(cfg *profileInspectionConfig) (engin
|
||||
return engineSettings{}, err
|
||||
}
|
||||
cfg.diagnostics = diagnostics
|
||||
return engineSettings{profileDir: settings.ProfileDir, backends: settings.Backends, transientRetries: settings.TransientRetries}, nil
|
||||
return engineSettings{promptkitSources: settings.PromptKitSources, schemaDir: settings.SchemaDir, transientRetries: settings.TransientRetries}, nil
|
||||
}
|
||||
|
||||
func parsePromptInspectionArgs(args []string) (*promptInspectionConfig, error) {
|
||||
@@ -171,7 +170,9 @@ func parsePromptInspectionArgs(args []string) (*promptInspectionConfig, error) {
|
||||
fs := flag.NewFlagSet("inspect prompt", flag.ContinueOnError)
|
||||
fs.SetOutput(io.Discard)
|
||||
registerConfigSelectionFlags(fs, &cfg.configPath, &cfg.configOverlay)
|
||||
fs.StringVar(&cfg.promptDir, "prompt-dir", "", "directory containing prompt definitions")
|
||||
var promptkitSources promptKitSourceFlagValue
|
||||
fs.Var(&promptkitSources, "promptkit-source", "selected PromptKit source path (repeatable)")
|
||||
fs.StringVar(&cfg.schemaDir, "schema-dir", "", "base directory for validation schemas")
|
||||
fs.StringVar(&cfg.promptID, "prompt", "", "prompt ID to inspect")
|
||||
fs.StringVar(&cfg.promptVersion, "prompt-version", "", "optional prompt version")
|
||||
rawFormat := ""
|
||||
@@ -205,8 +206,5 @@ func resolveAppSettingsForPromptInspection(cfg *promptInspectionConfig) (engineS
|
||||
return engineSettings{}, err
|
||||
}
|
||||
cfg.diagnostics = diagnostics
|
||||
if strings.TrimSpace(settings.PromptDir) == "" {
|
||||
return engineSettings{}, errors.New(errPromptDirRequired)
|
||||
}
|
||||
return engineSettings{promptDir: settings.PromptDir, backends: settings.Backends, transientRetries: settings.TransientRetries}, nil
|
||||
return engineSettings{promptkitSources: settings.PromptKitSources, schemaDir: settings.SchemaDir, transientRetries: settings.TransientRetries}, nil
|
||||
}
|
||||
|
||||
@@ -28,15 +28,10 @@ const (
|
||||
ExitValidationFailed = 2
|
||||
)
|
||||
|
||||
const (
|
||||
errPromptDirRequired = "prompt directory is required; provide --prompt-dir or config.yml prompt_dir"
|
||||
)
|
||||
|
||||
type runConfig struct {
|
||||
configPath string
|
||||
|
||||
promptDir string
|
||||
profileDir string
|
||||
promptkitSources []appconfig.SourceSelection
|
||||
promptID string
|
||||
promptVersion string
|
||||
profileID string
|
||||
@@ -53,7 +48,6 @@ type runConfig struct {
|
||||
topP float64
|
||||
reasoningEffort string
|
||||
schemaDir string
|
||||
backends []appconfig.BackendSettings
|
||||
timeout time.Duration
|
||||
runTimeout time.Duration
|
||||
transientRetries int
|
||||
@@ -83,22 +77,19 @@ type serveConfig struct {
|
||||
configPath string
|
||||
|
||||
addr string
|
||||
promptDir string
|
||||
profileDir string
|
||||
promptkitSources []appconfig.SourceSelection
|
||||
schemaDir string
|
||||
artifactRoot string
|
||||
maxRequestBytes int64
|
||||
maxArtifactBytes int64
|
||||
maxResponseBytes int64
|
||||
backends []appconfig.BackendSettings
|
||||
transientRetries *int
|
||||
diagnostics []configkit.Diagnostic
|
||||
configOverlay string
|
||||
}
|
||||
|
||||
type commonCommandSettings struct {
|
||||
promptDir string
|
||||
profileDir string
|
||||
promptkitSources []appconfig.SourceSelection
|
||||
schemaDir string
|
||||
serverAddr string
|
||||
artifactRoot string
|
||||
@@ -106,7 +97,6 @@ type commonCommandSettings struct {
|
||||
maxArtifactBytes int64
|
||||
maxResponseBytes int64
|
||||
defaultRenderFormat renderformat.PreparedRunOutputFormat
|
||||
backends []appconfig.BackendSettings
|
||||
transientRetries *int
|
||||
diagnostics []configkit.Diagnostic
|
||||
}
|
||||
@@ -164,7 +154,11 @@ func runCommand(args []string, stdout, stderr io.Writer) int {
|
||||
|
||||
engine, err := newEngine(cfg.engineSettings())
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "engine error: %v\n", err)
|
||||
writeApplicationError(stderr, "engine", err)
|
||||
return ExitRuntimeError
|
||||
}
|
||||
if err := writeFrameworkDiagnostics(stderr, engine); err != nil {
|
||||
fmt.Fprintf(stderr, "engine diagnostic write error: %v\n", err)
|
||||
return ExitRuntimeError
|
||||
}
|
||||
return executeRun(cfg, req, engine.Run, stdout, stderr)
|
||||
@@ -242,7 +236,11 @@ func renderCommand(args []string, stdout, stderr io.Writer) int {
|
||||
|
||||
engine, err := newEngine(cfg.runConfig.engineSettings())
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "engine error: %v\n", err)
|
||||
writeApplicationError(stderr, "engine", err)
|
||||
return ExitRuntimeError
|
||||
}
|
||||
if err := writeFrameworkDiagnostics(stderr, engine); err != nil {
|
||||
fmt.Fprintf(stderr, "engine diagnostic write error: %v\n", err)
|
||||
return ExitRuntimeError
|
||||
}
|
||||
|
||||
@@ -283,7 +281,11 @@ func serveCommand(args []string, stderr io.Writer) int {
|
||||
|
||||
engine, err := newEngine(cfg.engineSettings(), promptkit.WithArtifactReader(artifactReader))
|
||||
if err != nil {
|
||||
fmt.Fprintf(stderr, "engine error: %v\n", err)
|
||||
writeApplicationError(stderr, "engine", err)
|
||||
return ExitRuntimeError
|
||||
}
|
||||
if err := writeFrameworkDiagnostics(stderr, engine); err != nil {
|
||||
fmt.Fprintf(stderr, "engine diagnostic write error: %v\n", err)
|
||||
return ExitRuntimeError
|
||||
}
|
||||
|
||||
@@ -400,8 +402,8 @@ func parseServeArgs(args []string) (*serveConfig, error) {
|
||||
|
||||
registerConfigSelectionFlags(fs, &cfg.configPath, &cfg.configOverlay)
|
||||
fs.StringVar(&cfg.addr, "addr", "", "HTTP listen address")
|
||||
fs.StringVar(&cfg.promptDir, "prompt-dir", "", "directory containing prompt definition YAML files")
|
||||
fs.StringVar(&cfg.profileDir, "profile-dir", "", "directory containing execution profile YAML files")
|
||||
var promptkitSources promptKitSourceFlagValue
|
||||
fs.Var(&promptkitSources, "promptkit-source", "selected PromptKit source path (repeatable)")
|
||||
fs.StringVar(&cfg.schemaDir, "schema-dir", "", "base directory for validation schemas")
|
||||
fs.StringVar(&cfg.artifactRoot, "artifact-root", "", "base directory for HTTP file input artifacts")
|
||||
fs.Int64Var(&cfg.maxRequestBytes, "max-request-bytes", 0, "maximum HTTP request body bytes; 0 disables the limit")
|
||||
@@ -420,28 +422,22 @@ func parseServeArgs(args []string) (*serveConfig, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cfg.promptDir = settings.promptDir
|
||||
cfg.profileDir = settings.profileDir
|
||||
cfg.promptkitSources = settings.promptkitSources
|
||||
cfg.schemaDir = settings.schemaDir
|
||||
cfg.addr = settings.serverAddr
|
||||
cfg.artifactRoot = settings.artifactRoot
|
||||
cfg.maxRequestBytes = settings.maxRequestBytes
|
||||
cfg.maxArtifactBytes = settings.maxArtifactBytes
|
||||
cfg.maxResponseBytes = settings.maxResponseBytes
|
||||
cfg.backends = settings.backends
|
||||
cfg.transientRetries = settings.transientRetries
|
||||
cfg.diagnostics = settings.diagnostics
|
||||
|
||||
if err := validateRequiredLibraryDirs(cfg.promptDir); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
func registerExecutionRequestFlags(fs *flag.FlagSet, cfg *runConfig) {
|
||||
fs.StringVar(&cfg.promptDir, "prompt-dir", "", "directory containing prompt definition YAML files")
|
||||
fs.StringVar(&cfg.profileDir, "profile-dir", "", "directory containing execution profile YAML files")
|
||||
var promptkitSources promptKitSourceFlagValue
|
||||
fs.Var(&promptkitSources, "promptkit-source", "selected PromptKit source path (repeatable)")
|
||||
fs.StringVar(&cfg.promptID, "prompt", "", "prompt ID to run")
|
||||
fs.StringVar(&cfg.promptVersion, "prompt-version", "", "optional prompt definition version")
|
||||
fs.StringVar(&cfg.profileID, "profile", "", "optional execution profile ID; if omitted, prompt default_profile is used")
|
||||
@@ -472,17 +468,12 @@ func finalizeExecutionRequestConfig(fs *flag.FlagSet, cfg *runConfig) error {
|
||||
return err
|
||||
}
|
||||
|
||||
cfg.promptDir = settings.promptDir
|
||||
cfg.profileDir = settings.profileDir
|
||||
cfg.promptkitSources = settings.promptkitSources
|
||||
cfg.schemaDir = settings.schemaDir
|
||||
cfg.defaultRenderFormat = settings.defaultRenderFormat
|
||||
cfg.backends = settings.backends
|
||||
cfg.configuredTransientRetries = settings.transientRetries
|
||||
cfg.diagnostics = settings.diagnostics
|
||||
|
||||
if err := validateRequiredLibraryDirs(cfg.promptDir); err != nil {
|
||||
return err
|
||||
}
|
||||
if strings.TrimSpace(cfg.promptID) == "" {
|
||||
return errors.New("--prompt is required")
|
||||
}
|
||||
@@ -524,8 +515,7 @@ func resolveCommonSettings(fs *flag.FlagSet, configPath, overlay string) (common
|
||||
return commonCommandSettings{}, err
|
||||
}
|
||||
return commonCommandSettings{
|
||||
promptDir: settings.PromptDir,
|
||||
profileDir: settings.ProfileDir,
|
||||
promptkitSources: settings.PromptKitSources,
|
||||
schemaDir: settings.SchemaDir,
|
||||
serverAddr: settings.ServerAddr,
|
||||
artifactRoot: settings.ArtifactRoot,
|
||||
@@ -533,54 +523,50 @@ func resolveCommonSettings(fs *flag.FlagSet, configPath, overlay string) (common
|
||||
maxArtifactBytes: settings.MaxArtifactBytes,
|
||||
maxResponseBytes: settings.MaxResponseBytes,
|
||||
defaultRenderFormat: settings.DefaultRenderFormat,
|
||||
backends: settings.Backends,
|
||||
transientRetries: settings.TransientRetries,
|
||||
diagnostics: diagnostics,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func validateRequiredLibraryDirs(promptDir string) error {
|
||||
if strings.TrimSpace(promptDir) == "" {
|
||||
return errors.New(errPromptDirRequired)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type engineSettings struct {
|
||||
promptDir string
|
||||
profileDir string
|
||||
promptkitSources []appconfig.SourceSelection
|
||||
schemaDir string
|
||||
backends []appconfig.BackendSettings
|
||||
transientRetries *int
|
||||
}
|
||||
|
||||
func (c runConfig) engineSettings() engineSettings {
|
||||
return engineSettings{promptDir: c.promptDir, profileDir: c.profileDir, schemaDir: c.schemaDir, backends: c.backends, transientRetries: c.configuredTransientRetries}
|
||||
return engineSettings{promptkitSources: c.promptkitSources, schemaDir: c.schemaDir, transientRetries: c.configuredTransientRetries}
|
||||
}
|
||||
|
||||
func (c serveConfig) engineSettings() engineSettings {
|
||||
return engineSettings{promptDir: c.promptDir, profileDir: c.profileDir, schemaDir: c.schemaDir, backends: c.backends, transientRetries: c.transientRetries}
|
||||
return engineSettings{promptkitSources: c.promptkitSources, schemaDir: c.schemaDir, transientRetries: c.transientRetries}
|
||||
}
|
||||
|
||||
func newEngine(settings engineSettings, options ...promptkit.Option) (*promptkit.Engine, error) {
|
||||
engineOptions := make([]promptkit.Option, 0, len(settings.backends)+len(options))
|
||||
for _, configured := range settings.backends {
|
||||
engineOptions = append(engineOptions, promptkit.WithBackend(promptkit.Backend{
|
||||
ID: configured.ID,
|
||||
Endpoint: configured.Endpoint,
|
||||
APIKeyEnv: configured.APIKeyEnv,
|
||||
ExtraParams: configured.ExtraParams,
|
||||
ConcurrencyLimit: configured.ConcurrencyLimit,
|
||||
QueueCapacity: configured.QueueCapacity,
|
||||
}))
|
||||
underlays := make([]configkit.Underlay, 0, len(settings.promptkitSources))
|
||||
for index, selection := range settings.promptkitSources {
|
||||
var inputs []configkit.Input
|
||||
switch {
|
||||
case selection.File != "" && selection.Directory == "":
|
||||
inputs = []configkit.Input{{Source: configkit.File(selection.File), Imports: true}}
|
||||
case selection.Directory != "" && selection.File == "":
|
||||
var err error
|
||||
inputs, err = promptkit.DirectoryInputs(selection.Directory)
|
||||
if err != nil {
|
||||
cause := fmt.Errorf("PromptKit source %d directory %q: %w", index+1, selection.Directory, err)
|
||||
return nil, fmt.Errorf("engine initialization from application configuration: %w", errors.Join(promptkit.ErrInvalidConfig, cause))
|
||||
}
|
||||
default:
|
||||
cause := fmt.Errorf("PromptKit source %d must select exactly one file or directory", index+1)
|
||||
return nil, fmt.Errorf("engine initialization from application configuration: %w", errors.Join(promptkit.ErrInvalidConfig, cause))
|
||||
}
|
||||
underlays = append(underlays, configkit.Underlay{Inputs: inputs})
|
||||
}
|
||||
engineOptions = append(engineOptions, options...)
|
||||
engine, err := promptkit.NewEngine(promptkit.Config{
|
||||
PromptDir: settings.promptDir,
|
||||
ProfileDir: settings.profileDir,
|
||||
Sources: promptkit.ConfigurationSources{Underlays: underlays},
|
||||
SchemaDir: settings.schemaDir,
|
||||
TransientRetries: settings.transientRetries,
|
||||
}, engineOptions...)
|
||||
}, options...)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("engine initialization from application configuration: %w", err)
|
||||
}
|
||||
@@ -755,10 +741,10 @@ func runErrorMessage(err error) string {
|
||||
|
||||
func printUsage(w io.Writer) {
|
||||
fmt.Fprintln(w, "usage: scriptorium <run|render|serve|inspect|config> ...")
|
||||
fmt.Fprintln(w, " run: scriptorium run [--config PATH] [--config-overlay NAME] [--prompt-dir DIR] [--profile-dir DIR] [--schema-dir DIR] --prompt ID [--prompt-version VERSION] [--input name=path] [--profile ID] [--session-id ID] [--llm-base-url URL] [--model NAME] [--api-key-env ENV] [--temperature N] [--max-tokens N] [--top-p N] [--reasoning-effort VALUE] [--var k=v] [--out path] [--execution-report path] [--timeout 10m] [--run-timeout 10m] [--transient-retries N]")
|
||||
fmt.Fprintln(w, " render: scriptorium render [--config PATH] [--config-overlay NAME] [--prompt-dir DIR] [--profile-dir DIR] [--schema-dir DIR] --prompt ID [--prompt-version VERSION] [--input name=path] [--profile ID] [--session-id ID] [--llm-base-url URL] [--model NAME] [--api-key-env ENV] [--temperature N] [--max-tokens N] [--top-p N] [--reasoning-effort VALUE] [--var k=v] [--format text|json] [--out path] [--timeout 10m] [--transient-retries N]")
|
||||
fmt.Fprintf(w, " serve: scriptorium serve [--config PATH] [--config-overlay NAME] [--addr %s] [--prompt-dir DIR] [--profile-dir DIR] [--schema-dir DIR] [--artifact-root DIR] [--max-request-bytes N] [--max-artifact-bytes N] [--max-response-bytes N]\n", defaults.HTTPAddrDefault)
|
||||
fmt.Fprintln(w, " inspect prompt: scriptorium inspect prompt --prompt ID [--prompt-version VERSION] [--config PATH] [--config-overlay NAME] [--prompt-dir DIR] [--format text|json] [--out path]")
|
||||
fmt.Fprintln(w, " inspect profile: scriptorium inspect profile --profile ID [--config PATH] [--config-overlay NAME] [--profile-dir DIR] [--format text|json] [--out path]")
|
||||
fmt.Fprintln(w, " run: scriptorium run [--config PATH] [--config-overlay NAME] [--promptkit-source PATH ...] [--schema-dir DIR] --prompt ID [--prompt-version VERSION] [--input name=path] [--profile ID] [--session-id ID] [--llm-base-url URL] [--model NAME] [--api-key-env ENV] [--temperature N] [--max-tokens N] [--top-p N] [--reasoning-effort VALUE] [--var k=v] [--out path] [--execution-report path] [--timeout 10m] [--run-timeout 10m] [--transient-retries N]")
|
||||
fmt.Fprintln(w, " render: scriptorium render [--config PATH] [--config-overlay NAME] [--promptkit-source PATH ...] [--schema-dir DIR] --prompt ID [--prompt-version VERSION] [--input name=path] [--profile ID] [--session-id ID] [--llm-base-url URL] [--model NAME] [--api-key-env ENV] [--temperature N] [--max-tokens N] [--top-p N] [--reasoning-effort VALUE] [--var k=v] [--format text|json] [--out path] [--timeout 10m] [--transient-retries N]")
|
||||
fmt.Fprintf(w, " serve: scriptorium serve [--config PATH] [--config-overlay NAME] [--promptkit-source PATH ...] [--addr %s] [--schema-dir DIR] [--artifact-root DIR] [--max-request-bytes N] [--max-artifact-bytes N] [--max-response-bytes N]\n", defaults.HTTPAddrDefault)
|
||||
fmt.Fprintln(w, " inspect prompt: scriptorium inspect prompt --prompt ID [--prompt-version VERSION] [--config PATH] [--config-overlay NAME] [--promptkit-source PATH ...] [--schema-dir DIR] [--format text|json] [--out path]")
|
||||
fmt.Fprintln(w, " inspect profile: scriptorium inspect profile --profile ID [--config PATH] [--config-overlay NAME] [--promptkit-source PATH ...] [--schema-dir DIR] [--format text|json] [--out path]")
|
||||
fmt.Fprintln(w, " config: scriptorium config <validate|show|sources|explain> [--config PATH] [--config-overlay NAME] [application overrides] [--path /pointer for explain]")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user