tpmjs/packages/tools/official/diff-text-unified
Ajax Davis 5c9f1a1d0a chore: update dependencies with compatibility fixes
- Update all packages to latest versions via pnpm update --latest
- Downgrade Prisma 7 to 6 (v7 requires schema migration)
- Downgrade Tailwind CSS 4 to 3 (v4 requires PostCSS migration)
- Downgrade Storybook 10 to 8 (addons not available in v10)
- Pin cheerio to 1.0.0-rc.12 via pnpm override (type exports changed)
- Fix AI SDK tool definitions: parameters -> inputSchema
- Fix cheerio types in extract-meta and table-extract tools
- Add explicit type annotations to tool execute functions
- Migrate biome config to v2.3.11 schema

All type-checks, tests, and builds pass.
2026-01-09 22:49:41 +10:00
..
src feat: add 100+ official TPMJS tools 2025-12-31 22:55:56 +10:00
CHANGELOG.md chore: version packages 2025-12-31 23:54:47 +10:00
package.json chore: update dependencies with compatibility fixes 2026-01-09 22:49:41 +10:00
README.md feat: add 100+ official TPMJS tools 2025-12-31 22:55:56 +10:00
tsconfig.json feat: add 100+ official TPMJS tools 2025-12-31 22:55:56 +10:00
tsup.config.ts feat: add 100+ official TPMJS tools 2025-12-31 22:55:56 +10:00

@tpmjs/tools-diff-text-unified

Creates unified diff between two text strings with context lines.

Installation

npm install @tpmjs/tools-diff-text-unified

Usage

import { diffTextUnified } from '@tpmjs/tools-diff-text-unified';
import { generateText } from 'ai';

const result = await generateText({
  model: yourModel,
  tools: {
    diffTextUnified,
  },
  prompt: 'Compare these two versions and show me what changed',
});

Tool Details

diffTextUnified

Creates a unified diff between two text strings, showing additions, deletions, and context lines.

Parameters:

  • original (string, required) - The original text to compare from
  • modified (string, required) - The modified text to compare to
  • contextLines (number, optional) - Number of context lines to show around changes (default: 3)

Returns:

{
  diff: string;          // The unified diff string
  additions: number;     // Number of lines added
  deletions: number;     // Number of lines deleted
  changes: number;       // Total changes (additions + deletions)
  hasChanges: boolean;   // Whether any changes were detected
  summary: string;       // Human-readable summary
}

Example Output

{
  diff: `--- original
+++ modified
@@ -1,3 +1,3 @@
 function hello() {
-  console.log('Hello');
+  console.log('Hello, World!');
 }`,
  additions: 1,
  deletions: 1,
  changes: 2,
  hasChanges: true,
  summary: "1 addition, 1 deletion"
}

Features

  • Creates standard unified diff format
  • Configurable context lines
  • Counts additions and deletions
  • Provides human-readable summary
  • Works with any text content (code, documents, etc.)

License

MIT