Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 0 additions & 97 deletions cmd/claude_hook.go

This file was deleted.

17 changes: 1 addition & 16 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,7 @@ var createCmd = &cobra.Command{
// Fire post_create hook if configured
wsPath := filepath.Join(cfg.WorkspaceDir, name)
vars := lifecycle.Vars{Name: name, Path: wsPath, Branch: branch}
if err := lifecycle.Run("post_create", vars); errors.Is(err, lifecycle.ErrNoHook) {
// TODO: remove when matured — legacy fallback for users without [hooks] config.
copyParentCLAUDEmd(wsPath)
} else if err != nil {
if err := lifecycle.Run("post_create", vars); err != nil && !errors.Is(err, lifecycle.ErrNoHook) {
console.Warningf("post_create hook failed: %s", err)
}
},
Expand All @@ -166,18 +163,6 @@ func init() {
createCmd.RegisterFlagCompletionFunc("preset", completePresetNames)
}

// TODO: remove when matured — legacy fallback for users without [hooks] config.
func copyParentCLAUDEmd(wsPath string) {
src := filepath.Join(wsPath, "..", "CLAUDE.md")
data, err := os.ReadFile(src)
if err != nil {
return
}
if err := os.WriteFile(filepath.Join(wsPath, "CLAUDE.md"), data, 0o644); err != nil {
console.Warningf("legacy CLAUDE.md copy failed: %s", err)
}
}

func deriveName(branch string) string {
name := strings.ReplaceAll(branch, "/", "-")
name = strings.ReplaceAll(name, " ", "-")
Expand Down
11 changes: 11 additions & 0 deletions cmd/delete.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package cmd

import (
"errors"
"fmt"
"strings"

"github.com/nicksenap/grove/internal/console"
"github.com/nicksenap/grove/internal/lifecycle"
"github.com/nicksenap/grove/internal/picker"
"github.com/nicksenap/grove/internal/state"
"github.com/nicksenap/grove/internal/workspace"
Expand Down Expand Up @@ -68,6 +70,15 @@ func doDelete(args []string, force bool) {
}

for _, name := range names {
// Fire pre_delete hook before teardown (e.g. harvest Claude memory)
ws, _ := state.GetWorkspace(name)
if ws != nil {
vars := lifecycle.Vars{Name: name, Path: ws.Path, Branch: ws.Branch}
if err := lifecycle.Run("pre_delete", vars); err != nil && !errors.Is(err, lifecycle.ErrNoHook) {
console.Warningf("pre_delete hook failed: %s", err)
}
}

if err := workspace.NewService().Delete(name); err != nil {
exitError(err.Error())
}
Expand Down
39 changes: 0 additions & 39 deletions cmd/doctor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ import (
"encoding/json"
"fmt"
"os"
"path/filepath"

"github.com/nicksenap/grove/internal/config"
"github.com/nicksenap/grove/internal/console"
"github.com/nicksenap/grove/internal/models"
"github.com/nicksenap/grove/internal/workspace"
"github.com/spf13/cobra"
)
Expand All @@ -27,8 +24,6 @@ var doctorCmd = &cobra.Command{
exitError(err.Error())
}

// TODO: remove when matured — nudge users to migrate to [hooks] config.
issues = append(issues, checkMissingHooks()...)

if doctorJSON {
data, _ := json.MarshalIndent(issues, "", " ")
Expand Down Expand Up @@ -57,40 +52,6 @@ var doctorCmd = &cobra.Command{
},
}

// TODO: remove when matured — nudge users to migrate to [hooks] config.
func checkMissingHooks() []models.DoctorIssue {
cfg, err := config.Load()
if err != nil || cfg == nil {
return nil
}

var issues []models.DoctorIssue

if _, ok := cfg.Hooks["on_close"]; !ok {
// Only flag if Zellij is present — that's what the old hardcoded behavior supported.
if os.Getenv("ZELLIJ_SESSION_NAME") != "" {
issues = append(issues, models.DoctorIssue{
Workspace: "—",
Issue: "no on_close hook configured (using legacy Zellij fallback)",
SuggestedAction: "add [hooks] on_close to ~/.grove/config.toml",
})
}
}

if _, ok := cfg.Hooks["post_create"]; !ok {
// Only flag if ~/.claude exists — user is a Claude Code user.
home, _ := os.UserHomeDir()
if _, err := os.Stat(filepath.Join(home, ".claude")); err == nil {
issues = append(issues, models.DoctorIssue{
Workspace: "—",
Issue: "no post_create hook configured (using legacy CLAUDE.md copy)",
SuggestedAction: `add [hooks] post_create = "cp {path}/../CLAUDE.md {path}/CLAUDE.md 2>/dev/null || true"`,
})
}
}

return issues
}

func init() {
doctorCmd.Flags().BoolVar(&doctorFix, "fix", false, "Auto-fix issues")
Expand Down
17 changes: 3 additions & 14 deletions cmd/go_cmd.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package cmd

import (
"errors"
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"

"errors"
"os/exec"
"syscall"

"github.com/nicksenap/grove/internal/config"
Expand Down Expand Up @@ -43,9 +42,7 @@ var goCmd = &cobra.Command{
}
}
if err := lifecycle.Run("on_close", lifecycle.Vars{}); errors.Is(err, lifecycle.ErrNoHook) {
// TODO: remove when matured — legacy Zellij fallback for users who
// upgraded before the [hooks] system existed.
zellijCloseFallback()
exitError("No on_close hook configured. Set one in ~/.grove/config.toml:\n\n [hooks]\n on_close = \"gw zellij close-pane\"")
} else if err != nil {
exitError(fmt.Sprintf("on_close hook failed: %s", err))
}
Expand Down Expand Up @@ -205,14 +202,6 @@ func deleteAsync(name string) {
cmd.Start() // fire and forget
}

// TODO: remove when matured — legacy Zellij fallback for users without [hooks] config.
func zellijCloseFallback() {
if os.Getenv("ZELLIJ_SESSION_NAME") == "" {
exitError("No on_close hook configured. Set one in ~/.grove/config.toml:\n\n [hooks]\n on_close = \"zellij action close-pane\"")
}
exec.Command("zellij", "action", "close-pane").Run()
}

func init() {
goCmd.Flags().BoolVarP(&goBack, "back", "b", false, "Go back to source repo")
goCmd.Flags().BoolVarP(&goDelete, "delete", "d", false, "Delete workspace after navigating away")
Expand Down
41 changes: 0 additions & 41 deletions cmd/hook.go

This file was deleted.

2 changes: 2 additions & 0 deletions cmd/init_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ var initCmd = &cobra.Command{
if len(repos) > 0 {
console.Infof("Found %d repo(s) in configured directories", len(repos))
}

console.Infof("Run 'gw wizard' to set up plugins and hooks")
},
}
3 changes: 1 addition & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ func init() {
addDirCmd,
removeDirCmd,
runCmd,
hookCmd,
claudeHookCmd,
exploreCmd,
mcpServeCmd,
pluginCmd,
wizardCmd,
)
}

Expand Down
Loading
Loading