clarify

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 12 Imported by: 0

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

func BuildContext(qas []QA) string

BuildContext formats Q&A pairs into a structured context block suitable for injection into the decomposition prompt.

func ClarificationPath

func ClarificationPath(workDir string) string

ClarificationPath returns the path to the Q&A audit file.

func IsTTY

func IsTTY() bool

IsTTY returns true when os.Stdin is an interactive terminal.

func QuestionsPrompt

func QuestionsPrompt(goal, instructions string) string

QuestionsPrompt builds the prompt asking the AI to generate clarifying questions.

Types

type QA

type QA struct {
	Question string `json:"question"`
	Answer   string `json:"answer"`
}

QA holds a single clarifying question and the user's answer.

func Load

func Load(workDir string) ([]QA, error)

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:

  1. Calls the AI provider to generate 3-5 questions about the goal.
  2. Presents each question to the user interactively on the terminal.
  3. Collects answers via scanner.
  4. Saves Q&A pairs to .cloop/clarification.json.
  5. 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL