summaryrefslogtreecommitdiff
path: root/internal/api/validate.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/api/validate.go')
-rw-r--r--internal/api/validate.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/api/validate.go b/internal/api/validate.go
index 07d293c..9e91882 100644
--- a/internal/api/validate.go
+++ b/internal/api/validate.go
@@ -7,11 +7,29 @@ import (
"fmt"
"net/http"
"os/exec"
+ "strings"
"time"
)
const validateTimeout = 20 * time.Second
+// claudeJSONResult is the top-level object returned by `claude --output-format json`.
+type claudeJSONResult struct {
+ Result string `json:"result"`
+ IsError bool `json:"is_error"`
+}
+
+// extractJSON returns the first top-level JSON object found in s, stripping
+// surrounding prose or markdown code fences the model may have added.
+func extractJSON(s string) string {
+ start := strings.Index(s, "{")
+ end := strings.LastIndex(s, "}")
+ if start == -1 || end == -1 || end < start {
+ return s
+ }
+ return s[start : end+1]
+}
+
const validateSystemPrompt = `You are a task instruction reviewer for Claudomator, an AI task runner that executes tasks by running Claude or Gemini as a subprocess.
Analyze the given task name and instructions for clarity and completeness.