refine

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

cmd/project/plan/refine/refine.go

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, args []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 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 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