fix: smart_edit — add output field, Claude-style diff, normalization typo #38

Merged
FO
4mo ago
+333-125

Bugs Fixed

  1. Missing output field — caused h.split error in tool framework
  2. Normalization typo — === normalizedSlice (self-compare, always true)
  3. No diff output — now shows Claude-style ● Update(file) blocks

Changes

  • src/tools/smart-edit.ts: Added formatDiff() + proper ToolResult return + typo fix
  • tests/smart-edit.test.ts: Updated assertions for new { title, output, metadata } format

Closes #38


Summary by cubic

Standardizes ToolResult ({ title, output, metadata }) across tools and adds a Claude‑style diff to smart-edit with better alignment and context. Fixes normalized matching and improves outputs for batch_patch, file_tree, research, smart_patch, and solution_confidence; pins @opencode-ai/plugin.

  • New Features

    • smart-edit: Adds Claude‑style diff with added/removed counts, improved lookahead realignment that emits the matched line as context, and clear titles.
  • Bug Fixes

    • Standardized { title, output, metadata } returns across smart_edit, smart_patch, batch_patch, file_tree, research, solution_confidence; fixes normalized match check; clearer batch rollback and single‑file file‑tree responses; tests updated; uses (ctx as any).callTool(...) where needed; pins @opencode-ai/plugin to 1.15.13.
    • research: Validates queries as an array of strings and enforces scope to brain|web|both; safer typed callTool usage; returns a titled JSON summary.

Summary by CodeRabbit

  • New Features
    • Smart edit now provides a Claude-style diff and richer match/method details in its response.
    • Several tools now return standardized, structured responses (title, output, metadata) for clearer results (file browsing, research, patching, confidence).
  • Bug Fixes
    • Improved edit matching and error reporting for exact vs whitespace-tolerant updates.
    • Batch patching and rollback now return consistent, detailed success/failure summaries.
  • Tests
    • Updated test assertions to validate the new structured response shapes via metadata.
  • Chores
    • Bumped version to 0.4.2 and pinned @opencode-ai/plugin to 1.15.13.