Skip to content

LeoYeAI/agent-master-skills / skills/ai-humanizer

humanizer

Verified

Humanize AI-generated text by detecting and removing patterns typical of LLM output. Rewrites text to sound natural, specific, and human. Uses 24 pattern detectors, 500+ AI vocabulary terms across 3 tiers, and statistical analysis (burstiness, type-token ratio, readability) for comprehensive detection. Use when asked to humanize text, de-AI writing, make content sound more natural/human, review writing for AI patterns, score text for AI detection, or improve AI-generated drafts. Covers content, language, style, communication, and filler categories.

FileKindSize
README.mdmarkdown15.8 KB
SKILL.mdskill md7.8 KB
assets/banner.mdmarkdown331 B
docs/CONTRIBUTING.mdmarkdown2.0 KB
docs/EXAMPLES.mdmarkdown5.3 KB
docs/PATTERNS.mdmarkdown2.4 KB
eslint.config.jsscript559 B
package.jsonmanifest1.3 KB
references/ai-vocabulary.mdmarkdown5.5 KB
references/patterns.mdmarkdown10.0 KB
references/style-guide.mdmarkdown3.9 KB
scripts/analyze.shscript301 B
scripts/humanize.shscript315 B
src/analyzer.jsscript14.8 KB
src/cli.jsscript19.6 KB
src/humanizer.jsscript14.2 KB
src/patterns.jsscript28.1 KB
src/stats.jsscript9.5 KB
src/vocabulary.jsscript15.1 KB
tests/analyzer.test.jsscript13.2 KB
tests/calibration.test.jsscript7.2 KB
tests/edge-cases.test.jsscript7.1 KB
tests/fixtures/ai-sample-1.txtmarkdown2.2 KB
tests/fixtures/ai-sample-2.txtmarkdown1.1 KB
tests/fixtures/human-sample-1.txtmarkdown1.1 KB
tests/humanizer.test.jsscript6.4 KB
tests/performance.test.jsscript3.2 KB
tests/statistics.test.jsscript7.9 KB
vitest.config.jsscript152 B

tests/statistics.test.js

View on GitHub
/**
 * statistics.test.js — Tests for the text statistics engine (stats.js).
 */

import { describe, it, expect } from 'vitest';
import {
  computeStats,
  computeUniformityScore,
  computeNgramRepetition,
  splitSentences,
  tokenize,
  estimateSyllables,
} from '../src/stats.js';

// ─── Tokenize ────────────────────────────────────────────

describe('tokenize', () => {
  it('splits text into lowercase words', () => {
    const result = tokenize('Hello World');
    expect(result).toContain('hello');
    expect(result).toContain('world');
  });

  it('strips punctuation', () => {
    const result = tokenize('Hello, world! How are you?');
    expect(result).toContain('hello');
    expect(result).not.toContain('hello,');
  });

  it('handles empty input', () => {
    expect(tokenize('')).toEqual([]);
  });
});

// ─── Sentence Splitting ─────────────────────────────────

describe('splitSentences', () => {
  it('splits on periods', () => {
    const result = splitSentences('Hello world. How are you. Fine.');
    expect(result.length).toBeGreaterThanOrEqual(2);
  });

  it('splits on question marks and exclamation points', () => {
    const result = splitSentences('What? Really! Yes.');
    expect(result.length).toBeGreaterThanOrEqual(2);
  });

  it('handles single sentence', () => {
    const result = splitSentences('Just one sentence.');
    expect(result.length).toBe(1);
  });

  it('handles abbreviations', () => {
    const result = splitSentences('Dr. Smith went home. Mr. Jones followed.');
    // Should split into 2 sentences, not 4
    expect(result.length).toBe(2);
  });
});

// ─── Syllable Estimation ─────────────────────────────────

describe('estimateSyllables', () => {
  it('counts single-syllable words', () => {
    expect(estimateSyllables('cat')).toBe(1);
    expect(estimateSyllables('the')).toBe(1);
  });

  it('counts multi-syllable words', () => {
    expect(estimateSyllables('beautiful')).toBeGreaterThanOrEqual(2);
    expect(estimateSyllables('computer')).toBeGreaterThanOrEqual(2);
  });

  it('returns at least 1 for any word', () => {
    expect(estimateSyllables('a')).toBeGreaterThanOrEqual(1);
    expect(estimateSyllables('xyz')).toBeGreaterThanOrEqual(1);
  });
});

// ─── N-gram Repetition ──────────────────────────────────

describe('computeNgramRepetition', () => {
  it('returns 0 for short input', () => {
    expect(computeNgramRepetition(['the', 'cat'], 3)).toBe(0);
  });

  it('detects repeated trigrams', () => {
    const words = 'the cat sat the cat sat the cat sat'.split(' ');
    const rep = computeNgramRepetition(words, 3);
    expect(rep).toBeGreaterThan(0);
  });

  it('returns 0 for all unique trigrams', () => {
    const words = 'one two three four five six seven eight nine ten'.split(' ');
    const rep = computeNgramRepetition(words, 3);
    expect(rep).toBe(0);
  });
});

// ─── computeStats ────────────────────────────────────────

describe('computeStats', () => {
  it('returns valid structure for normal text', () => {
    const text = 'This is a test. Another sentence here. And a third one too.';
    const stats = computeStats(text);

    expect(stats).toHaveProperty('wordCount');
    expect(stats).toHaveProperty('sentenceCount');
    expect(stats).toHaveProperty('burstiness');
    expect(stats).toHaveProperty('typeTokenRatio');
    expect(stats).toHaveProperty('functionWordRatio');
    expect(stats).toHaveProperty('fleschKincaid');
    expect(stats).toHaveProperty('paragraphCount');
    expect(stats).toHaveProperty('trigramRepetition');
  });

  it('handles empty input', () => {
    const stats = computeStats('');
    expect(stats.wordCount).toBe(0);
    expect(stats.sentenceCount).toBe(0);
  });

  it('handles null input', () => {
    const stats = computeStats(null);
    expect(stats.wordCount).toBe(0);
  });

  // Sentence stats
  it('counts sentences correctly', () => {
    const text = 'First sentence. Second sentence. Third sentence.';
    const stats = computeStats(text);
    expect(stats.sentenceCount).toBe(3);
  });

  it('computes average sentence length', () => {
    const text = 'Short one. This is a bit longer sentence.';
    const stats = computeStats(text);
    expect(stats.avgSentenceLength).toBeGreaterThan(0);
  });

  it('computes burstiness', () => {
    // Very uniform sentences → low burstiness
    const uniform = 'The cat sat down. The dog ran fast. The cow ate hay. The fox was sly.';
    const uniformStats = computeStats(uniform);

    // Very varied sentences → higher burstiness
    const varied =
      'Hi. This is a much longer sentence with many more words in it that goes on and on for a while. OK.';
    const variedStats = computeStats(varied);

    expect(variedStats.burstiness).toBeGreaterThan(uniformStats.burstiness);
  });

  // Vocabulary stats
  it('counts total and unique words', () => {
    const text = 'The cat and the dog and the bird.';
    const stats = computeStats(text);
    expect(stats.wordCount).toBeGreaterThan(0);
    expect(stats.uniqueWordCount).toBeLessThanOrEqual(stats.wordCount);
  });

  it('computes type-token ratio', () => {
    const repetitive = 'the the the the dog the the the the cat';
    const repStats = computeStats(repetitive);

    const diverse = 'cats dogs birds fish horses cows sheep goats pigs';
    const divStats = computeStats(diverse);

    expect(divStats.typeTokenRatio).toBeGreaterThan(repStats.typeTokenRatio);
  });

  // Paragraph stats
  it('counts paragraphs', () => {
    const text = 'Paragraph one.\n\nParagraph two.\n\nParagraph three.';
    const stats = computeStats(text);
    expect(stats.paragraphCount).toBe(3);
  });

  // Readability
  it('computes Flesch-Kincaid grade level', () => {
    const text = 'The cat sat on the mat. The dog ate the bone. The bird flew away.';
    const stats = computeStats(text);
    expect(stats.fleschKincaid).toBeDefined();
    expect(typeof stats.fleschKincaid).toBe('number');
  });

  // Function word ratio
  it('computes function word ratio', () => {
    const text = 'The cat is in the box with the hat on the mat.';
    const stats = computeStats(text);
    expect(stats.functionWordRatio).toBeGreaterThan(0);
    expect(stats.functionWordRatio).toBeLessThan(1);
  });
});

// ─── computeUniformityScore ──────────────────────────────

describe('computeUniformityScore', () => {
  it('returns 0 for empty stats', () => {
    const stats = computeStats('');
    expect(computeUniformityScore(stats)).toBe(0);
  });

  it('returns higher score for uniform text', () => {
    // Uniform sentences — should score higher (more AI-like)
    const uniform =
      'This is a sentence. Here is another one. And there is one more. Plus yet another sentence. One final sentence too.';
    const uniformStats = computeStats(uniform);
    const uniformScore = computeUniformityScore(uniformStats);

    // Varied sentences — should score lower (more human-like)
    const varied =
      'Short. This is a much much longer sentence that really goes on for a while with many more words. Medium one here. Yes. And then this one wraps up with a moderate number of words.';
    const variedStats = computeStats(varied);
    const variedScore = computeUniformityScore(variedStats);

    expect(uniformScore).toBeGreaterThanOrEqual(variedScore);
  });

  it('returns a number between 0 and 100', () => {
    const text = 'The cat sat. The dog ran. The bird flew. The fish swam.';
    const stats = computeStats(text);
    const score = computeUniformityScore(stats);
    expect(score).toBeGreaterThanOrEqual(0);
    expect(score).toBeLessThanOrEqual(100);
  });
});
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall