Skip to main content

Diff Tools

Category: diff · 3 tools

Create and apply unified diffs for safe, auditable file edits.

Tools​

ToolParametersDescription
diff.createoldContent, newContentGenerate a unified diff
diff.applypath, patchApply a patch to a file
diff.previewpath, patchPreview patch result without applying

Examples​

Creating Diffs​

const stream = toolpack.stream({
messages: [{ role: 'user', content: 'Show me a diff of the changes you want to make' }],
model: 'gpt-4o',
});
// AI uses diff.create

Applying Patches​

const stream = toolpack.stream({
messages: [{ role: 'user', content: 'Apply this patch to the file' }],
model: 'gpt-4o',
});
// AI uses diff.apply

Previewing Changes​

const stream = toolpack.stream({
messages: [{ role: 'user', content: 'Preview what this patch would do' }],
model: 'gpt-4o',
});
// AI uses diff.preview

Use Cases​

  • Safe edits - Preview changes before applying
  • Code review - Generate diffs for review
  • Rollback - Create reverse patches