npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bernierllc/content-workflow-ai-rewrite-step

v0.3.0

Published

AI-powered content rewriting workflow step for transforming technical to readable content

Readme

@bernierllc/content-workflow-ai-rewrite-step

AI-powered content rewriting workflow step for transforming technical to readable content.

Features

  • Transform technical commit messages into readable blog content
  • Rewrite text for different tones and audiences
  • Improve clarity and engagement
  • Track changes made during rewriting
  • Support for long-form content with automatic chunking
  • Optional NeverHub integration for event tracking
  • Intelligent AI provider routing with cost optimization

Installation

npm install @bernierllc/content-workflow-ai-rewrite-step

Usage

Basic Usage

import { AIRewriteStep } from '@bernierllc/content-workflow-ai-rewrite-step';

// Create the step
const rewriteStep = new AIRewriteStep();

// Initialize (optional, enables NeverHub if available)
await rewriteStep.initialize();

// Execute the rewrite
const result = await rewriteStep.execute(
  {
    id: 'ai-rewrite-step',
    aiConfig: {
      prompt: 'Rewrite this for a general audience'
    }
  },
  {
    content: {
      id: 'content-123',
      body: 'Complex technical content here...'
    },
    workflowId: 'workflow-456'
  }
);

if (result.success && result.data) {
  console.log('Original:', result.data.originalText);
  console.log('Rewritten:', result.data.rewrittenText);
  console.log('Changes:', result.data.changes);
  console.log('Cost:', result.data.costUsd);
}

Custom AI Configuration

const result = await rewriteStep.execute(
  {
    id: 'ai-rewrite-step',
    aiConfig: {
      prompt: 'Make this sound professional and authoritative',
      provider: 'anthropic',
      model: 'claude-3-sonnet',
      maxTokens: 2000,
      temperature: 0.7,
      maxChunkSize: 5000
    }
  },
  context
);

With Custom Router and Logger

import { AIRewriteStep } from '@bernierllc/content-workflow-ai-rewrite-step';
import { AIProviderRouter } from '@bernierllc/ai-provider-router';
import { createLogger } from '@bernierllc/logger';

const router = new AIProviderRouter({
  providers: [
    {
      name: 'openai',
      priority: 1,
      enabled: true,
      costPer1kTokens: 0.002
    },
    {
      name: 'anthropic',
      priority: 2,
      enabled: true,
      costPer1kTokens: 0.003
    }
  ],
  strategy: 'least-cost'
});

const logger = createLogger({ level: 2 });

const rewriteStep = new AIRewriteStep({ router, logger });

API Reference

AIRewriteStep

Main class implementing the AI rewrite workflow step.

Constructor Options

interface AIRewriteStepOptions {
  router?: AIProviderRouter;
  logger?: Logger;
  neverhub?: NeverHubAdapter;
}

Methods

initialize(): Promise<void>

Initialize the step and auto-detect NeverHub if available.

execute(config, context): Promise<WorkflowStepExecutionResult>

Execute the rewrite operation.

Parameters:

  • config: WorkflowStepConfig - Step configuration
  • context: WorkflowContext - Workflow execution context

Returns: WorkflowStepExecutionResult with rewrite data

ChangeTracker

Utility class for tracking and analyzing changes.

import { ChangeTracker } from '@bernierllc/content-workflow-ai-rewrite-step';

const tracker = new ChangeTracker();
tracker.addChange('tone', 'Changed to conversational');
tracker.addChange('clarity', 'Simplified technical terms');

console.log(tracker.getChanges());
console.log(tracker.getChangeCountByType('tone'));
console.log(tracker.hasChanges());

Static Methods

analyzeChanges(explanation: string): RewriteChange[]

Extract changes from AI's explanation text.

compareTexts(original: string, rewritten: string): TextDifference

Compare two texts and identify basic differences.

Types

AIRewriteResult

interface AIRewriteResult {
  originalText: string;
  rewrittenText: string;
  changes: RewriteChange[];
  provider: string;
  model: string;
  tokensUsed: number;
  costUsd: number;
}

RewriteChange

interface RewriteChange {
  type: 'tone' | 'clarity' | 'audience' | 'technical';
  description: string;
}

AIRewriteConfig

interface AIRewriteConfig {
  prompt?: string;
  provider?: string;
  model?: string;
  maxTokens?: number;
  temperature?: number;
  maxChunkSize?: number;
}

Examples

Transform Technical Commit to Blog Post

const result = await rewriteStep.execute(
  {
    id: 'ai-rewrite-step',
    aiConfig: {
      prompt: `Transform this git commit message into an engaging blog post.
      Make it readable for non-technical audiences while preserving key information.`
    }
  },
  {
    content: {
      id: 'commit-123',
      body: `feat(auth): implement JWT-based authentication with refresh tokens

      - Added JWT token generation with RS256 signing
      - Implemented refresh token rotation strategy
      - Added token revocation via Redis blacklist`
    },
    workflowId: 'blog-workflow'
  }
);

Adjust Tone for Different Audiences

// For technical audience
const technicalResult = await rewriteStep.execute(
  {
    id: 'ai-rewrite-step',
    aiConfig: {
      prompt: 'Rewrite this for a technical audience. Use precise terminology.'
    }
  },
  context
);

// For general audience
const generalResult = await rewriteStep.execute(
  {
    id: 'ai-rewrite-step',
    aiConfig: {
      prompt: 'Rewrite this for a general audience. Avoid jargon and simplify concepts.'
    }
  },
  context
);

Handle Long-Form Content

// Content longer than maxChunkSize will be automatically split
const longContentResult = await rewriteStep.execute(
  {
    id: 'ai-rewrite-step',
    aiConfig: {
      prompt: 'Improve clarity and engagement',
      maxChunkSize: 4000 // Characters per chunk
    }
  },
  {
    content: {
      id: 'article-123',
      body: veryLongArticleText // 20,000+ characters
    },
    workflowId: 'editorial-workflow'
  }
);

NeverHub Integration

When NeverHub is available, the step automatically:

  • Registers as a workflow step service
  • Emits ai.rewrite.completed events on success
  • Emits ai.rewrite.failed events on error

Events include metadata like provider, cost, tokens used, and change count.

Error Handling

const result = await rewriteStep.execute(config, context);

if (!result.success) {
  console.error('Rewrite failed:', result.error);
  console.log('Metadata:', result.metadata);
}

Performance Considerations

  • Chunking: Long content is automatically split to respect AI provider token limits
  • Cost Tracking: All operations track tokens used and estimated cost
  • Provider Selection: Use provider: 'auto' for automatic cost-optimized routing
  • Caching: Consider caching results for identical inputs (implement externally)

License

Copyright (c) 2025 Bernier LLC

This file is licensed to the client under a limited-use license. The client may use and modify this code only within the scope of the project it was delivered for. Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.