# brand-voice

Brand-voice & tone-of-voice intelligence microservice for content teams: analyze any sample text into a structured voice profile (tone, formality, sentence-length/reading-level, warmth, energy, and...


A tone-of-voice intelligence microservice for content teams. Deterministic lexical/statistical cores
run fully offline; `rewrite` (and `analyze`'s tone label) also try an optional LLM via
`../_shared/llm.js` and silently fall back. Results are tagged `mode: 'heuristic' | 'llm'`.

Voice **profiles are passed in the args object** — `analyze` produces one, the other tools consume it.
(DB-backed profile persistence lands later.)

## Tools

| Tool | Args | What it does |
|---|---|---|
| `analyze` | `{ text }` | Turns sample text into a structured voice profile: `tone`, `formality`/`energy`/`warmth` (0–1), `readingLevel` (Flesch-Kincaid), `avgSentenceLength`, detected `traits` (playful, authoritative, technical, empathetic, salesy, minimalist, bold…), and a distinctive `lexicon`. Hybrid (LLM refines the tone label). |
| `rewrite` | `{ text, profile? \| target?, strength? }` | Rewrites copy to match a supplied profile (or a named `target` tone). Rule-based diction/formality/energy shifts offline; LLM does a full on-brand rewrite when available. Hybrid. |
| `guidelines` | `{ profile? \| target? }` | Renders a do/don't style-guide sheet from a profile, plus signature phrases and a target reading level. |
| `checkConsistency` | `{ text, profile? \| target? }` | Scores new text against a profile (0–100 `score` + verdict), with per-dimension deviations and flagged off-brand phrases. |

A `target` name (`professional`, `casual`, `playful`, `authoritative`, `empathetic`, `minimalist`,
`technical`, `bold`) can stand in for a full profile in `rewrite`/`guidelines`/`checkConsistency`.

## Example

```js
import pack from './index.js';
const { ...profile } = await pack.adapters.analyze({ text: 'Hey! We're gonna make your day awesome. Let's go!' });
pack.adapters.guidelines({ profile });
pack.adapters.checkConsistency({ text: 'Pursuant to the foregoing, kindly proceed.', profile });
await pack.adapters.rewrite({ text: 'We utilize advanced systems.', target: 'casual' });
```

## DRY boundaries

- Generic tokenizing/sentiment/readability of arbitrary prose → `nlp` / `a-text`. This pack owns
  brand-voice modeling (profile vector, on-brand rewriting, consistency scoring).
- No cross-pack imports except `../_shared/llm.js`.


---
Source: shared/engines/adapters/domain/brand-voice/README.md
Canonical: https://docs.leumas.tech/p/adapters/domain/brand-voice
