@@ -9,7 +9,6 @@ import (
99 "strings"
1010 "time"
1111
12- tea "charm.land/bubbletea/v2"
1312 "github.com/xonecas/symb/internal/hashline"
1413 "github.com/xonecas/symb/internal/lsp"
1514 "github.com/xonecas/symb/internal/mcp"
@@ -67,7 +66,7 @@ func NewEditTool() mcp.Tool {
6766 "description": "Anchor for first line to replace",
6867 "properties": map[string]interface{}{
6968 "line": map[string]interface{}{"type": "integer", "description": "1-indexed line number"},
70- "hash": map[string]interface{}{"type": "string", "description": "2-char hex hash from Open output"},
69+ "hash": map[string]interface{}{"type": "string", "description": "2-char hex hash from Read output"},
7170 },
7271 "required": []string{"line", "hash"},
7372 },
@@ -76,7 +75,7 @@ func NewEditTool() mcp.Tool {
7675 "description": "Anchor for last line to replace",
7776 "properties": map[string]interface{}{
7877 "line": map[string]interface{}{"type": "integer", "description": "1-indexed line number"},
79- "hash": map[string]interface{}{"type": "string", "description": "2-char hex hash from Open output"},
78+ "hash": map[string]interface{}{"type": "string", "description": "2-char hex hash from Read output"},
8079 },
8180 "required": []string{"line", "hash"},
8281 },
@@ -93,7 +92,7 @@ func NewEditTool() mcp.Tool {
9392 "description": "Anchor for the line to insert after",
9493 "properties": map[string]interface{}{
9594 "line": map[string]interface{}{"type": "integer", "description": "1-indexed line number"},
96- "hash": map[string]interface{}{"type": "string", "description": "2-char hex hash from Open output"},
95+ "hash": map[string]interface{}{"type": "string", "description": "2-char hex hash from Read output"},
9796 },
9897 "required": []string{"line", "hash"},
9998 },
@@ -110,7 +109,7 @@ func NewEditTool() mcp.Tool {
110109 "description": "Anchor for first line to delete",
111110 "properties": map[string]interface{}{
112111 "line": map[string]interface{}{"type": "integer", "description": "1-indexed line number"},
113- "hash": map[string]interface{}{"type": "string", "description": "2-char hex hash from Open output"},
112+ "hash": map[string]interface{}{"type": "string", "description": "2-char hex hash from Read output"},
114113 },
115114 "required": []string{"line", "hash"},
116115 },
@@ -119,7 +118,7 @@ func NewEditTool() mcp.Tool {
119118 "description": "Anchor for last line to delete",
120119 "properties": map[string]interface{}{
121120 "line": map[string]interface{}{"type": "integer", "description": "1-indexed line number"},
122- "hash": map[string]interface{}{"type": "string", "description": "2-char hex hash from Open output"},
121+ "hash": map[string]interface{}{"type": "string", "description": "2-char hex hash from Read output"},
123122 },
124123 "required": []string{"line", "hash"},
125124 },
@@ -142,10 +141,10 @@ func NewEditTool() mcp.Tool {
142141
143142 return mcp.Tool{
144143 Name: "Edit",
145- Description: `Edit a file using hash-anchored operations. You MUST Open the file first to get line hashes.
146-Each line from Open is tagged as "linenum:hash|content". Use the line number and hash as anchors.
144+ Description: `Edit a file using hash-anchored operations. You MUST Read the file first to get line hashes.
145+Each line from Read is tagged as "linenum:hash|content". Use the line number and hash as anchors.
147146 Exactly one operation per call: replace, insert, delete, or create.
148-If a hash does not match, the file changed since you read it — re-Open and retry.
147+If a hash does not match, the file changed since you read it — re-Read and retry.
149148 After each edit you receive fresh hashes — use those for subsequent edits, not the old ones.`,
150149 InputSchema: schemaJSON,
151150 }
@@ -153,7 +152,6 @@ After each edit you receive fresh hashes — use those for subsequent edits, not
153152
154153 // EditHandler handles Edit tool calls.
155154 type EditHandler struct {
156- program *tea.Program
157155 tracker *FileReadTracker
158156 lspManager *lsp.Manager
159157 }
@@ -163,11 +161,6 @@ func NewEditHandler(tracker *FileReadTracker, lspManager *lsp.Manager) *EditHand
163161 return &EditHandler{tracker: tracker, lspManager: lspManager}
164162 }
165163
166-// SetProgram sets the tea.Program instance after it's created.
167-func (h *EditHandler) SetProgram(program *tea.Program) {
168- h.program = program
169-}
170-
171164 // Handle implements the mcp.ToolHandler interface.
172165 func (h *EditHandler) Handle(ctx context.Context, arguments json.RawMessage) (*mcp.ToolResult, error) {
173166 var args EditArgs
@@ -218,9 +211,9 @@ func (h *EditHandler) Handle(ctx context.Context, arguments json.RawMessage) (*m
218211 return h.handleCreate(ctx, absPath, args.File, args.Create)
219212 }
220213
221- // Enforce read-before-edit: file must have been opened first
214+ // Enforce read-before-edit: file must have been Read first
222215 if !h.tracker.WasRead(absPath) {
223- return toolError("You must Open the file before editing it. Use Open to read %s first — you need the line hashes.", args.File), nil
216+ return toolError("You must Read the file before editing it. Use Read on %s first — you need the line hashes.", args.File), nil
224217 }
225218
226219 // All other ops require reading the existing file
@@ -248,17 +241,6 @@ func (h *EditHandler) Handle(ctx context.Context, arguments json.RawMessage) (*m
248241 return toolError("Failed to write file: %v", err), nil
249242 }
250243
251- // Show updated file in TUI editor
252- language := DetectLanguage(args.File)
253- if h.program != nil {
254- h.program.Send(OpenForUserMsg{
255- Content: result,
256- Language: language,
257- FilePath: args.File,
258- AbsPath: absPath,
259- })
260- }
261-
262244 // Return hashline-tagged view of the updated file
263245 tagged := hashline.TagLines(result, 1)
264246 taggedOutput := hashline.FormatTagged(tagged)
@@ -292,17 +274,6 @@ func (h *EditHandler) handleCreate(ctx context.Context, absPath, displayPath str
292274 return toolError("Failed to create file: %v", err), nil
293275 }
294276
295- // Show in TUI
296- language := DetectLanguage(displayPath)
297- if h.program != nil {
298- h.program.Send(OpenForUserMsg{
299- Content: op.Content,
300- Language: language,
301- FilePath: displayPath,
302- AbsPath: absPath,
303- })
304- }
305-
306277 tagged := hashline.TagLines(op.Content, 1)
307278 taggedOutput := hashline.FormatTagged(tagged)
308279