From f8423ebea413605b42de23f5dd06c5479d3fa1dd Mon Sep 17 00:00:00 2001 From: Ethan Werner Date: Sat, 10 Oct 2026 20:55:33 +0000 Subject: initial commit --- src/goal.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/goal.h (limited to 'src/goal.h') diff --git a/src/goal.h b/src/goal.h new file mode 100644 index 0000000..6ef823d --- /dev/null +++ b/src/goal.h @@ -0,0 +1,53 @@ +#ifndef LLSH_GOAL_H +#define LLSH_GOAL_H + +#include "util.h" + +/* Pure helpers for the /goal goal-based loop (mirrors goal.rs): parse the + * command, build each attempt's prompt, parse the evaluator's verdict. + * Side-effect free; the evaluator's model call lives in the session and the + * iteration loop in main. */ + +#define GOAL_DEFAULT_MAX_TRIES 5UL + +/* Parsed /goal command: success criteria + attempt cap. */ +typedef struct { + char *criteria; /* owned */ + unsigned long max_tries; +} goal_spec; + +/* Evaluator's judgment of a single attempt. reason is owned. */ +typedef struct { + bool met; + char *reason; +} goal_verdict; + +/* Summary of a finished /goal run. criteria is owned. */ +typedef struct { + char *criteria; + unsigned long max_tries; + unsigned long turns_done; + unsigned long long tokens_used; + bool met; +} goal_report; + +void goal_spec_free(goal_spec *s); +void goal_report_free(goal_report *r); + +/* System preamble for the tool-less goal evaluator. */ +const char *goal_evaluator_preamble(void); + +/* Parse "[, stop after tries]". + * Returns 1 on success (fills *out), 0 on failure (*err set, caller frees). */ +int goal_parse(const char *input, goal_spec *out, char **err); + +/* Prompt for a goal attempt (attempt starts at 1; feedback may be NULL). + * Caller frees. */ +char *goal_prompt(const goal_spec *spec, unsigned long attempt, + const char *feedback); + +/* Parse the evaluator's reply into a verdict (conservative: met only when + * MET appears and NOT MET does not). Caller frees out->reason. */ +void goal_parse_verdict(const char *reply, goal_verdict *out); + +#endif -- cgit v1.3.1