review

package
v0.7.0-alpha.6 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package review provides the command to generate code review prompts.

Index

Constants

This section is empty.

Variables

View Source
var ReviewCmd = &cobra.Command{
	Use:   "review [files...]",
	Short: "Generates a prompt for an AI code quality review.",
	Args:  cobra.MinimumNArgs(1),
	RunE: func(cmd *cobra.Command, args []string) error {
		presenter := ui.NewPresenter(cmd.OutOrStdout(), cmd.ErrOrStderr())

		tmpl, err := template.New("review-prompt").Parse(reviewPromptTemplate)
		if err != nil {
			return fmt.Errorf("failed to parse prompt template: %w", err)
		}

		var promptBuf bytes.Buffer

		if err := tmpl.Execute(&promptBuf, nil); err != nil {
			return fmt.Errorf("failed to render prompt template: %w", err)
		}

		// 2. Read and Format File Content
		var codeContent strings.Builder
		for _, filePath := range args {

			content, err := os.ReadFile(filePath)
			if err != nil {
				return fmt.Errorf("failed to read file '%s': %w", filePath, err)
			}

			codeContent.WriteString(fmt.Sprintf("\n--- FILE: %s ---\n", filePath))
			codeContent.WriteString("```go\n")
			codeContent.Write(content)
			codeContent.WriteString("\n```\n")
		}

		presenter.Header("--- Copy the text below to your AI ---")

		fmt.Println(promptBuf.String())

		fmt.Println(codeContent.String())
		presenter.Header("--- End of Prompt ---")

		presenter.Success("Review prompt generated for %d file(s).", len(args))

		return nil
	},
}

ReviewCmd represents the craft review command.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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