|
| 1 | +# @veldica/prose-linter |
| 2 | + |
| 3 | +A deterministic style-contract library and AI-writing style audit for high-quality prose. |
| 4 | + |
| 5 | +`@veldica/prose-linter` provides the engine for evaluating text against explicit structural targets (sentence length, lexical density, scannability) and identifies common "AI-style" markers. It is designed to be used programmatically in CLIs, editors, and agent feedback loops. |
| 6 | + |
| 7 | +## Features |
| 8 | + |
| 9 | +- **Deterministic Style Contracts**: Define targets for word counts, complexity, and structural variety. |
| 10 | +- **AI Marker Inventory**: Detect stock phrases, assistant residue, and repetitive structural patterns common in LLM output. |
| 11 | +- **Actionable Revision Levers**: Get prioritized advice on how to fix style violations. |
| 12 | +- **Readability Integration**: Built-in support for Gunning-Fog, Flesch-Kincaid, and more. |
| 13 | + |
| 14 | +## Installation |
| 15 | + |
| 16 | +```bash |
| 17 | +npm install @veldica/prose-linter |
| 18 | +``` |
| 19 | + |
| 20 | +## API Usage |
| 21 | + |
| 22 | +### Linting Text |
| 23 | + |
| 24 | +The `lintText` function is the primary entry point for evaluating text against a profile. |
| 25 | + |
| 26 | +```typescript |
| 27 | +import { lintText } from '@veldica/prose-linter'; |
| 28 | + |
| 29 | +const profile = { |
| 30 | + targets: { |
| 31 | + sentence_metrics: { |
| 32 | + avg_words_per_sentence: { value: 20, operator: 'at_most' }, |
| 33 | + sentence_length_stddev: { value: 5, operator: 'at_least' } |
| 34 | + } |
| 35 | + }, |
| 36 | + track_ai_patterns: true |
| 37 | +}; |
| 38 | + |
| 39 | +const result = lintText("Your prose goes here...", profile); |
| 40 | + |
| 41 | +console.log(result.summary.score); // Fit score out of 100 |
| 42 | +console.log(result.violations); // Array of failed CheckResults |
| 43 | +``` |
| 44 | + |
| 45 | +### Inventory AI Markers |
| 46 | + |
| 47 | +Audit a document specifically for "AI-ish" patterns without full structural linting. |
| 48 | + |
| 49 | +```typescript |
| 50 | +import { inventoryMarkers } from '@veldica/prose-linter'; |
| 51 | + |
| 52 | +const analysis = inventoryMarkers(text, { track_ai_patterns: true }); |
| 53 | + |
| 54 | +console.log(analysis.style_band); // "low" | "moderate" | "high" | "very_high" |
| 55 | +console.log(analysis.matches); // Array of matches with line/column locations |
| 56 | +``` |
| 57 | + |
| 58 | +## Result Structure |
| 59 | + |
| 60 | +The `LintResult` object returned by `lintText` includes: |
| 61 | + |
| 62 | +- `summary`: High-level compliance numbers (score, counts). |
| 63 | +- `checks`: All checks performed (passed, failed, and skipped). |
| 64 | +- `violations`: Specifically failed checks. |
| 65 | +- `skipped_checks`: Checks that couldn't be run due to missing data. |
| 66 | +- `ai_analysis`: Detailed report on AI-style markers. |
| 67 | +- `revision_levers`: Ranked suggestions for improvement. |
| 68 | + |
| 69 | +## License |
| 70 | + |
| 71 | +MIT |
0 commit comments