DiffWriter
Human-in-the-loop file writing with diff display and approval.
Installation
main.py
API
write(path, content)
Write content to a file with diff display and user approval.
main.py
diff(path, content)
Show diff without writing (preview mode).
main.py
read(path)
Read file contents.
main.py
Approval Options
When a file change is proposed, user sees:
╭─── Changes to hello.py ────────────────────────╮
│ --- a/hello.py │
│ +++ b/hello.py │
│ @@ -1,2 +1,3 @@ │
│ def hello(): │
│ - pass │
│ + print("Hello!") │
╰────────────────────────────────────────────────╯
Choose an option:
1 - Yes, apply this change
2 - Yes to all (auto-approve for this session)
3 - No, and tell agent what to do instead
Apply changes to hello.py? [1/2/3]:
1 - Yes, apply this change
2 - Yes to all (auto-approve for this session)
3 - No, and tell agent what to do instead
Apply changes to hello.py? [1/2/3]:
| Option | Effect |
|---|---|
| 1 | Apply this change, ask again for next change |
| 2 | Apply this and all future changes (session-wide) |
| 3 | Reject + provide feedback for agent to try again |
Options
auto_approve
Skip approval prompts (for automation).
main.py
Use with Agent
main.py
Feedback Flow
When user chooses option 3 (reject):
- User is prompted: "What should the agent do instead?"
- User types feedback, e.g., "use snake_case for function names"
- Agent receives:
"User rejected changes to hello.py. Feedback: use snake_case for function names" - Agent can retry with the feedback
Common Use Cases
main.py
