From 6a8bba47cc544f1b4ae49a3b70ff589fe56cc550 Mon Sep 17 00:00:00 2001 From: seagochen Date: Mon, 9 Mar 2026 15:05:49 +0800 Subject: [PATCH] feat(commands): add /edit help subcommand /edit help, /edit --help, /edit -h all display full usage with examples. Co-Authored-By: Claude Sonnet 4.6 --- pkg/commands/cmd_edit.go | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/pkg/commands/cmd_edit.go b/pkg/commands/cmd_edit.go index bd770e65d..b9425d92d 100644 --- a/pkg/commands/cmd_edit.go +++ b/pkg/commands/cmd_edit.go @@ -1,13 +1,39 @@ package commands -import "context" +import ( + "context" + "strings" +) + +const editHelp = `Usage: + /edit — view file with line numbers + /edit — replace line N with text + /edit + — insert after line N + /edit - — delete line N + /edit -m """ — write full content (multi-line) + + """ + +Examples: + /edit main.go — view main.go + /edit main.go 5 func foo() — replace line 5 + /edit main.go +10 // note — insert after line 10 + /edit main.go -3 — delete line 3 + /edit README.md -m """ + # Title + Hello world + """ — overwrite file` func editCommand() Definition { return Definition{ Name: "edit", Description: "View or edit files (works in both chat and command mode)", - Usage: "/edit [operation]", + Usage: "/edit [operation] | /edit help", Handler: func(_ context.Context, req Request, rt *Runtime) error { + arg := strings.TrimSpace(strings.TrimPrefix(strings.TrimSpace(req.Text), "/edit")) + if arg == "help" || arg == "--help" || arg == "-h" { + return req.Reply(editHelp) + } if rt == nil || rt.EditFile == nil { return req.Reply(unavailableMsg) }