From 884eebc256b9c8a948004e38600954cab9d8a483 Mon Sep 17 00:00:00 2001 From: Ryan Orban Date: Wed, 1 Apr 2026 22:28:21 -0700 Subject: [PATCH] fix: register custom tasks in task list/show/run commands Custom tasks defined in config under tasks.custom were registered by the run and preview commands but not by the task subcommands. This meant `nightshift task list` only showed built-in tasks, and `nightshift task show/run ` returned "unknown task". Add registerCustomTasks() helper that loads config and calls RegisterCustomTasksFromConfig, matching the pattern already used in run.go and preview.go. Call it at the top of runTaskList, runTaskShow, and runTaskRun. --- cmd/nightshift/commands/task.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cmd/nightshift/commands/task.go b/cmd/nightshift/commands/task.go index 6b1820e..278a7ea 100644 --- a/cmd/nightshift/commands/task.go +++ b/cmd/nightshift/commands/task.go @@ -11,6 +11,7 @@ import ( "text/tabwriter" "time" + "github.com/marcus/nightshift/internal/config" "github.com/marcus/nightshift/internal/logging" "github.com/marcus/nightshift/internal/orchestrator" "github.com/marcus/nightshift/internal/security" @@ -18,6 +19,17 @@ import ( "github.com/spf13/cobra" ) +// registerCustomTasks loads config and registers any user-defined custom tasks +// so they appear in task list/show/run. Mirrors the registration in run.go. +func registerCustomTasks() { + cfg, err := config.Load() + if err != nil { + return + } + tasks.ClearCustom() + _ = tasks.RegisterCustomTasksFromConfig(cfg.Tasks.Custom) +} + var taskCmd = &cobra.Command{ Use: "task", Short: "Manage and run tasks", @@ -80,6 +92,8 @@ func init() { } func runTaskList(cmd *cobra.Command, args []string) error { + registerCustomTasks() + categoryFilter, _ := cmd.Flags().GetString("category") costFilter, _ := cmd.Flags().GetString("cost") asJSON, _ := cmd.Flags().GetBool("json") @@ -134,6 +148,8 @@ func runTaskList(cmd *cobra.Command, args []string) error { } func runTaskShow(cmd *cobra.Command, args []string) error { + registerCustomTasks() + taskType := tasks.TaskType(args[0]) promptOnly, _ := cmd.Flags().GetBool("prompt-only") asJSON, _ := cmd.Flags().GetBool("json") @@ -177,6 +193,8 @@ func runTaskShow(cmd *cobra.Command, args []string) error { } func runTaskRun(cmd *cobra.Command, args []string) error { + registerCustomTasks() + taskType := tasks.TaskType(args[0]) provider, _ := cmd.Flags().GetString("provider") projectPath, _ := cmd.Flags().GetString("project")