41 lines
1.4 KiB
Go
41 lines
1.4 KiB
Go
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
|
|
}
|