Documentation
¶
Overview ¶
Package tdd provides AI-generated acceptance criteria and post-execution test verification for cloop PM tasks.
The workflow is two-phase:
- GenerateCriteria (--generate mode): before task execution the AI writes acceptance criteria (criteria.md) and a runnable test script (test.sh) stored under .cloop/tdd/<task-id>/.
- RunTests (--verify mode): after task execution the stored test.sh is executed; the exit code and output are used to update TDDStatus on the task and append a result section to the task artifact.
Index ¶
- func AppendResultToArtifact(workDir string, task *pm.Task, result TestResult) error
- func CriteriaPath(workDir string, taskID int) string
- func GenerateCriteria(ctx context.Context, prov provider.Provider, opts provider.Options, ...) (string, string, error)
- func GenerateCriteriaPrompt(task *pm.Task) string
- func SaveCriteria(workDir string, taskID int, criteria, testScript string) error
- func TDDDir(workDir string, taskID int) string
- func TestScriptPath(workDir string, taskID int) string
- func VerifyPrompt(task *pm.Task, testOutput string) string
- type TestResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendResultToArtifact ¶
func AppendResultToArtifact(workDir string, task *pm.Task, result TestResult) error
AppendResultToArtifact appends TDD result information to the task artifact file. It is a best-effort operation; errors are returned but callers may ignore them.
func CriteriaPath ¶
CriteriaPath returns the path to the acceptance criteria Markdown file.
func GenerateCriteria ¶
func GenerateCriteria(ctx context.Context, prov provider.Provider, opts provider.Options, task *pm.Task) (string, string, error)
GenerateCriteria calls the AI provider to produce acceptance criteria and a test script for the task. Returns (criteriaMarkdown, shellScript, error).
func GenerateCriteriaPrompt ¶
GenerateCriteriaPrompt builds the AI prompt that produces acceptance criteria and a runnable test script for the given task.
func SaveCriteria ¶
SaveCriteria writes the criteria.md and test.sh files to .cloop/tdd/<taskID>/. The test script is made executable (0755).
Both files are written atomically (tmp + fsync + rename) so a crash mid-write cannot leave a half-truncated criteria.md (which RunTests would happily exec, producing a misleading verification result) or a partial test.sh that bash would refuse to parse on the next --verify run.
func TestScriptPath ¶
TestScriptPath returns the path to the runnable test script.
Types ¶
type TestResult ¶
TestResult holds the outcome of running the test script.
func RunTests ¶
func RunTests(workDir string, taskID int) (TestResult, error)
RunTests executes the test script for a task and returns the result. The script is run from workDir so relative paths resolve correctly. Returns an error only when the script cannot be found or started; a non-zero exit code is reported via TestResult.ExitCode, not as an error.