Home/Tools/@tpmjs/tools-style-rewrite

styleRewriteTool

@tpmjs/tools-style-rewrite

Rewrites text to match a style guide using find/replace rules. Supports simple string replacement with find/replace or advanced regex patterns with pattern/replacement. Returns the rewritten text along with details about what changed.

Official
documentation
v0.2.0
MIT

Interactive Playground

Test @tpmjs/tools-style-rewrite (styleRewriteTool) with AI-powered execution

0/2000 characters

Installation & Usage

Install this tool and use it with the AI SDK

1. Install the package

npm install @tpmjs/tools-style-rewrite
pnpm add @tpmjs/tools-style-rewrite
yarn add @tpmjs/tools-style-rewrite
bun add @tpmjs/tools-style-rewrite
deno add npm:@tpmjs/tools-style-rewrite

2. Import the tool

import { styleRewriteTool } from '@tpmjs/tools-style-rewrite';

3. Use with AI SDK

import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import { styleRewriteTool } from '@tpmjs/tools-style-rewrite';

const result = await generateText({
  model: openai('gpt-4o'),
  tools: { styleRewriteTool },
  prompt: 'Your prompt here...',
});

console.log(result.text);

Parameters

Available configuration options

Auto-extracted
text
Required
Type: string

The text to rewrite according to the style guide

rules
Required
Type: array

Array of style rules. Each rule can use find/replace for simple text replacement or pattern/replacement for regex-based replacement.

Schema extracted: 1/1/2026, 8:17:41 AM

README

ERROR: No README data found!

Statistics

Downloads/month

44

Quality Score

78%

Bundle Size

NPM Keywords

tpmjs
documentation
ai
style-guide
text-processing

Maintainers

thomasdavis(thomasalwyndavis@gmail.com)

Frameworks

vercel-ai