prdescription

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package prdescription provides the command to generate PR description prompts.

Index

Constants

This section is empty.

Variables

View Source
var PRDescriptionCmd = &cobra.Command{
	Use:     "pr-description",
	Aliases: []string{"pr"},
	Short:   "Generates a prompt for an AI to write your Pull Request description.",
	RunE: func(cmd *cobra.Command, _ []string) error {
		presenter := ui.NewPresenter(cmd.OutOrStdout(), cmd.ErrOrStderr())
		ctx := cmd.Context()

		gitCfg := git.GitClientConfig{
			Logger:                globals.AppLogger,
			DefaultRemoteName:     globals.LoadedAppConfig.Git.DefaultRemote,
			DefaultMainBranchName: globals.LoadedAppConfig.Git.DefaultMainBranch,
			Executor:              globals.ExecClient.UnderlyingExecutor(),
		}
		client, err := git.NewClient(ctx, ".", gitCfg)
		if err != nil {
			return fmt.Errorf("failed to initialize git client: %w", err)
		}

		mainBranch := client.MainBranchName()

		log, diff, err := client.GetLogAndDiffFromMergeBase(ctx, mainBranch)
		if err != nil {
			presenter.Error("Failed to get changes against '%s': %v", mainBranch, err)

			return fmt.Errorf("failed to get branch changes: %w", err)
		}

		prompt := fmt.Sprintf(`
# Role
You are a senior software engineer.

# Goal
Write a clear and comprehensive Pull Request description based on the following changes.

# Instructions
1.  **Summary**: Write a high-level summary of the problem solved and the solution.
2.  **Changes**: Use a bulleted list to detail specific changes.
3.  **Format**: Output raw Markdown suitable for a GitHub PR body.

# Commit History
%s

# Code Diff
~~~diff
%s
~~~
`, log, diff)

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

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

		presenter.Success("Prompt generated. Paste this into your AI chat.")

		return nil
	},
}

PRDescriptionCmd represents the craft pr-description 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