refine

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: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package refine provides the command to refine issues.

Index

Constants

This section is empty.

Variables

View Source
var RefineCmd = &cobra.Command{
	Use:     "refine",
	Short:   "Interactively classify untyped issues.",
	Example: `  contextvibes project plan refine`,
	RunE: func(cmd *cobra.Command, _ []string) error {
		presenter := ui.NewPresenter(cmd.OutOrStdout(), cmd.ErrOrStderr())
		ctx := cmd.Context()

		provider, err := newProvider(ctx, globals.AppLogger, globals.LoadedAppConfig)
		if err != nil {
			presenter.Error("Failed to initialize work item provider: %v", err)

			return err
		}

		presenter.Summary("Finding unclassified issues to refine...")

		query := "is:open is:issue -label:epic -label:story -label:bug -label:chore"
		items, err := provider.SearchItems(ctx, query)
		if err != nil {
			presenter.Error("Failed to search for unclassified issues: %v", err)

			return fmt.Errorf("failed to search items: %w", err)
		}

		if len(items) == 0 {
			presenter.Success("No unclassified issues found. The backlog is clean!")

			return nil
		}

		presenter.Info("Found %d unclassified issues. Starting refinement session...", len(items))
		presenter.Newline()

		for _, item := range items {
			var issueType string
			prompt := fmt.Sprintf("Classify #%d: %s", item.Number, item.Title)

			form := huh.NewForm(
				huh.NewGroup(
					huh.NewNote().Title(prompt).Description(item.Body),

					huh.NewSelect[string]().
						Title("What is the correct type for this issue?").
						Options(
							huh.NewOption("Epic", "epic"),
							huh.NewOption("Story", "story"),
							huh.NewOption("Task", "task"),
							huh.NewOption("Bug", "bug"),
							huh.NewOption("Chore", "chore"),
							huh.NewOption("Skip", "skip"),
						).
						Value(&issueType),
				),
			)

			err := form.Run()
			if err != nil {
				return fmt.Errorf("input form failed: %w", err)
			}

			if issueType != "skip" && issueType != "" {

				updatedItem := item
				updatedItem.Labels = append(updatedItem.Labels, issueType)
				updatedItem.Type = workitem.Type(
					issueType,
				)

				_, err := provider.UpdateItem(ctx, item.Number, updatedItem)
				if err != nil {
					presenter.Error(
						"Failed to apply label '%s' to issue #%d: %v",
						issueType,
						item.Number,
						err,
					)

				} else {
					presenter.Success("✓ Applied label '%s' to issue #%d.", issueType, item.Number)
				}
			} else {
				presenter.Info("Skipped issue #%d.", item.Number)
			}
			presenter.Newline()
		}

		presenter.Success("Refinement session complete.")

		return nil
	},
}

RefineCmd represents the project plan refine 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