Documentation
¶
Overview ¶
Package clarify implements an interactive goal clarification dialog. Before plan decomposition, the AI generates 3-5 clarifying questions about the goal (ambiguities, constraints, success criteria, tech stack preferences). Answers are collected from stdin and injected as structured context into the decomposition prompt, producing a better-scoped plan.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildContext ¶
BuildContext formats Q&A pairs into a structured context block suitable for injection into the decomposition prompt.
func ClarificationPath ¶
ClarificationPath returns the path to the Q&A audit file.
func QuestionsPrompt ¶
QuestionsPrompt builds the prompt asking the AI to generate clarifying questions.
Types ¶
type QA ¶
QA holds a single clarifying question and the user's answer.
func Load ¶
Load reads previously saved clarification Q&A from disk. Returns nil, nil when the file does not exist.
On parse failure (zero-byte file from a torn pre-atomicfile write, schema drift, manual edit gone wrong) the corrupt clarification.json is quarantined aside as clarification.json.corrupt-<unix> and (nil, nil) is returned. Refusing the load would block `cloop run --pm` from progressing to decomposition; treating the file as absent re-prompts the user (or proceeds without the audit when non-interactive), which is a recoverable path.
func Run ¶
func Run( ctx context.Context, p provider.Provider, model string, timeout time.Duration, goal, instructions, workDir string, scanner *bufio.Scanner, ) ([]QA, error)
Run executes the full clarification dialog:
- Calls the AI provider to generate 3-5 questions about the goal.
- Presents each question to the user interactively on the terminal.
- Collects answers via scanner.
- Saves Q&A pairs to .cloop/clarification.json.
- Returns the Q&A slice for injection into the decomposition prompt.
Returns nil, nil when stdin is not a TTY (non-interactive mode). The caller must ensure skip=true in automation contexts.