Add transcript passthrough processing

This commit is contained in:
2026-05-10 23:27:54 +00:00
parent 8f3c2ec5fd
commit 2cf2d390da
6 changed files with 173 additions and 28 deletions

View File

@@ -8,10 +8,9 @@ import (
"strings"
"gitea.maximumdirect.net/eric/audita/internal/core/config"
coreio "gitea.maximumdirect.net/eric/audita/internal/core/io"
)
const processNotImplementedMessage = "process command is not implemented yet"
type processInvocation struct {
TranscriptPath string
GlossaryPath string
@@ -20,9 +19,29 @@ type processInvocation struct {
Config config.Config
}
var processRunner = func(inv processInvocation) error {
_ = inv
return errors.New(processNotImplementedMessage)
var processRunner = func(inv processInvocation, stdout io.Writer) error {
transcriptBytes, err := coreio.ReadRequiredFile(inv.TranscriptPath, "transcript")
if err != nil {
return err
}
if err := coreio.ValidateWellFormedJSON(transcriptBytes); err != nil {
return err
}
if _, err := coreio.ReadRequiredFile(inv.GlossaryPath, "glossary"); err != nil {
return err
}
if strings.TrimSpace(inv.OutputPath) != "" {
if err := coreio.WriteFile(inv.OutputPath, transcriptBytes); err != nil {
return err
}
return nil
}
if _, err := stdout.Write(transcriptBytes); err != nil {
return fmt.Errorf("failed to write transcript to stdout: %w", err)
}
return nil
}
// Run executes the Audita CLI with the provided arguments and streams.
@@ -162,7 +181,7 @@ func runProcess(args []string, stdout, stderr io.Writer) int {
Config: cfg,
}
if err := processRunner(inv); err != nil {
if err := processRunner(inv, stdout); err != nil {
fmt.Fprintf(stderr, "audita process: %v\n", err)
return 1
}