Check prompt requirements before stage attempts
This commit is contained in:
40
internal/app/runner_preflight.go
Normal file
40
internal/app/runner_preflight.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/preflight"
|
||||
)
|
||||
|
||||
func inspectInvocationRequirements(runtime *invocationRuntime) error {
|
||||
if !stagesContainAny(runtime.stages, "trim", "analyze") {
|
||||
return nil
|
||||
}
|
||||
projection, err := projectSelectedWork(runtime.ctx, runtime.cfg, runtime.plan, runtime.opts.Force, runtime.opts.SelectedArtifacts, runtime.effectiveArtifacts, runtime.artifactStore, runtime.manifest)
|
||||
if err != nil {
|
||||
return fmt.Errorf("project prompt inspection work: %w", err)
|
||||
}
|
||||
targets, err := executionInspectionTargets(runtime.cfg, runtime.identity.SessionID, projection)
|
||||
if err != nil {
|
||||
return fmt.Errorf("select prompt inspection targets: %w", err)
|
||||
}
|
||||
if len(targets) == 0 {
|
||||
return nil
|
||||
}
|
||||
if runtime.env.Scriptorium == nil {
|
||||
runtime.env.Scriptorium = runtime.dependencies.newScriptorium()
|
||||
}
|
||||
if runtime.env.Scriptorium == nil {
|
||||
return fmt.Errorf("initialize scriptorium runner: no runner available")
|
||||
}
|
||||
result, err := preflight.Check(runtime.ctx, runtime.env.Scriptorium, targets)
|
||||
for _, finding := range result.Findings {
|
||||
if finding.Severity == preflight.SeverityWarning {
|
||||
runtime.env.Warn(finding.Message, "stage", finding.Stage, "artifact", finding.Artifact, "prompt", finding.PromptID, "issue", finding.IssueCode, "input", finding.InputName, "variable", finding.VariableName)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("scriptorium preflight: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user