Skip to content

feat: Add file edit API for external editor integration #4

Closed

Description

@dahai80

Background

Fusion Studio is building a Claude Code-style agentic coding experience. The Code module needs programmatic file editing capabilities from the backend.

Request

Add a JSON-RPC API that supports:

  1. File read/write — code.file_read(path) and code.file_write(path, content) methods
  2. Diff generation — code.diff(original, modified) returns unified diff
  3. Apply patch — code.apply_patch(path, patch) applies a unified diff to a file with backup
  4. File search — code.search_files(pattern, path) for codebase search

Use Case

When AI suggests code changes in Fusion Studio:

  1. User clicks "Apply Code"
  2. Studio calls code.diff(original, modified) to show preview
  3. User confirms → Studio calls code.apply_patch(path, patch) to write changes
  4. Checkpoint stored for undo

This mirrors the Claude Code agentic loop: Gather Context → Take Action → Verify Results.

API Design Sketch

{"method": "code.file_read", "params": {"path": "/path/to/file.swift"}}
{"method": "code.file_write", "params": {"path": "/path/to/file.swift", "content": "..."}}
{"method": "code.diff", "params": {"original": "...", "modified": "...", "language": "swift"}}
{"method": "code.apply_patch", "params": {"path": "/path/to/file.swift", "patch": "...", "backup": true}}
{"method": "code.search_files", "params": {"pattern": "func hello", "path": "/project", "max_results": 20}}

🤖 Generated with Claude Code

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