Skip to content

fix: smart_edit — add required output field + Claude-style diff formatting + normalization typo #38

Description

@four-bytes-robby

Bugs Found

  1. Missing output field: smart_edit.execute() returns { changed, line, matches, method } — but the plugin ToolResult contract requires { title, output: string, metadata? }. The missing output causes h.split error when opencode's truncation layer tries to process undefined.

  2. Normalization typo (line 96): normalizedSlice === normalizedSlice compares the same variable — always true. Should be normalizedSlice === normalizedOld. This made the bottom-up replacement loop run on every slice, not just matching ones.

  3. No diff output: Tool returns only metadata — no human-readable/LLM-readable diff showing what changed.

Fix

  • Return proper ToolResult with { title, output, metadata }
  • Add formatDiff() helper that produces Claude-style diff blocks:
    ● Update(src/file.ts)
      ⎿  Added X lines, removed Y lines
          <lineNum>  <context>
          <lineNum> -<removed>
          <lineNum> +<added>
    
  • Fix typo to correctly compare against normalizedOld
  • Update tests to match new return format

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions