From 74814646b1d8b97aa25fa1594dc63c9281aacaa3 Mon Sep 17 00:00:00 2001 From: Amolith Date: Wed, 29 Oct 2025 17:58:35 -0600 Subject: [PATCH] feat(cmd/r): implement session resumption Co-Authored-By: Crush --- cmd/r.go | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/cmd/r.go b/cmd/r.go index 737c611c1fecd95614de4e5a7d7d13de0b9e345c..1f8bfa65694701bc8b6d713f0f395c0dca42fe41 100644 --- a/cmd/r.go +++ b/cmd/r.go @@ -6,7 +6,10 @@ package cmd import ( "fmt" + "strings" + "git.secluded.site/np/cmd/shared" + "git.secluded.site/np/internal/task" "github.com/spf13/cobra" ) @@ -14,7 +17,54 @@ var rCmd = &cobra.Command{ Use: "r", Short: "Resume session", Long: `Resume an interrupted session in a new context window`, - Run: func(cmd *cobra.Command, args []string) { - fmt.Println("[STUB] Resume interrupted session from database") - }, + RunE: runResume, +} + +func runResume(cmd *cobra.Command, args []string) error { + env, err := shared.Environment(cmd) + if err != nil { + return err + } + + sessionDoc, found, err := shared.ActiveSession(cmd, env) + if err != nil { + return err + } + if !found { + return nil + } + + state, err := shared.PrintPlan(cmd, env, sessionDoc.SID) + if err != nil { + return err + } + + // Print instructions for resuming work + fmt.Fprintln(cmd.OutOrStdout(), strings.Repeat("-", 80)) + fmt.Fprintln(cmd.OutOrStdout(), "\nResuming session. To continue:") + fmt.Fprintln(cmd.OutOrStdout(), "1. Check the goal description above for any bug/issue/ticket ID. If present, read that ticket for full context.") + fmt.Fprintln(cmd.OutOrStdout(), "2. Read the files and symbols referenced in the pending tasks to understand what work remains.") + fmt.Fprintln(cmd.OutOrStdout(), "3. Update task status as you work: `np t u -i -s `") + fmt.Fprintln(cmd.OutOrStdout(), " Statuses: pending, in_progress, completed, failed, cancelled") + + // Provide context about pending work + pendingCount := 0 + inProgressCount := 0 + for _, t := range state.Tasks { + switch t.Status { + case task.StatusPending: + pendingCount++ + case task.StatusInProgress: + inProgressCount++ + } + } + + if inProgressCount > 0 { + fmt.Fprintf(cmd.OutOrStdout(), "\n%d task(s) are in progress.\n", inProgressCount) + } + if pendingCount > 0 { + fmt.Fprintf(cmd.OutOrStdout(), "%d task(s) are pending.\n", pendingCount) + } + + return nil }