root

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package root implements the ctx loop command.

It generates a Ralph loop shell script that runs an AI assistant iteratively until a completion signal is detected.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cmd

func Cmd() *cobra.Command

Cmd returns the "ctx loop" command for generating Ralph loop scripts.

The command generates a shell script that runs an AI assistant in a loop until a completion signal is detected, enabling iterative development where the AI builds on previous work.

Flags:

  • --prompt, -p: Prompt file to use (default "PROMPT.md")
  • --tool, -t: AI tool - claude, aider, or generic (default "claude")
  • --max-iterations, -n: Maximum iterations, 0 for unlimited (default 0)
  • --completion, -c: Completion signal to detect (default "SYSTEM_CONVERGED")
  • --output, -o: Output script filename (default "loop.sh")

Returns:

  • *cobra.Command: Configured loop command with flags registered

func GenerateLoopScript

func GenerateLoopScript(
	promptFile, tool string, maxIterations int, completionMsg string,
) string

GenerateLoopScript creates a bash script for running a Ralph loop.

The generated script runs the specified AI tool repeatedly with the same prompt file until a completion signal is detected in the output.

Parameters:

  • promptFile: Path to the prompt file (converted to absolute path)
  • tool: AI tool to use - "claude", "aider", or "generic"
  • maxIterations: Maximum iterations before stopping (0 for unlimited)
  • completionMsg: String to detect in output that signals completion

Returns:

  • string: Complete bash script content ready to write to file

func Run

func Run(
	cmd *cobra.Command,
	promptFile, tool string,
	maxIterations int,
	completionMsg, outputFile string,
) error

Run executes the loop command logic.

Validates the tool selection, generates the loop script, and writes it to the output file. Prints usage instructions after generation.

Parameters:

  • cmd: Cobra command for output stream
  • promptFile: Path to the prompt file for the AI
  • tool: AI tool to use (claude, aider, or generic)
  • maxIterations: Maximum loop iterations (0 for unlimited)
  • completionMsg: Signal string that indicates loop completion
  • outputFile: Path for the generated script

Returns:

  • error: Non-nil if the tool is invalid or file write fails

Types

This section is empty.

Jump to

Keyboard shortcuts

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