Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
buvard
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PLN
buvard
Commits
417cea83
Commit
417cea83
authored
Nov 07, 2026
by
PLN (Algolia)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: lint core moves to lib, package entry exports catalog + lint
parent
c9f7076d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
34 deletions
+48
-34
buvard.js
bin/buvard.js
+1
-32
index.mjs
lib/index.mjs
+4
-0
lint.mjs
lib/lint.mjs
+41
-0
package.json
package.json
+1
-1
buvard.test.mjs
test/buvard.test.mjs
+1
-1
No files found.
bin/buvard.js
View file @
417cea83
...
...
@@ -17,7 +17,7 @@
import
fs
from
'fs'
;
import
path
from
'path'
;
import
{
CATALOG
,
CATALOG_VERSION
,
BUDGETS
}
from
'../lib/catalog
.mjs'
;
import
{
CATALOG
_VERSION
,
lint
,
bodyOf
}
from
'../lib/index
.mjs'
;
const
TEXT_EXT
=
/
\.(
md|txt|mdx
)
$/i
;
...
...
@@ -34,37 +34,6 @@ function collect(target, files) {
console
.
error
(
`buvard: no file or directory for "
${
target
}
"`
);
}
/** Body = everything after the frontmatter fence (frontmatter is data, not prose). */
export
function
bodyOf
(
text
)
{
const
parts
=
text
.
split
(
'---'
);
return
parts
.
length
>=
3
&&
text
.
startsWith
(
'---'
)
?
parts
.
slice
(
2
).
join
(
'---'
).
trim
()
:
text
.
trim
();
}
export
function
lint
(
text
)
{
const
words
=
text
.
split
(
/
\s
+/
).
filter
(
Boolean
).
length
;
const
hits
=
[];
let
score
=
100
;
for
(
const
[
id
,
w
,
,
,
re
]
of
CATALOG
)
{
for
(
const
m
of
text
.
matchAll
(
re
))
{
hits
.
push
({
id
,
w
,
at
:
excerpt
(
text
,
m
.
index
)
});
score
-=
w
;
}
}
for
(
const
{
re
,
perWords
,
floor
,
id
,
weight
}
of
BUDGETS
)
{
const
budget
=
Math
.
max
(
floor
,
Math
.
floor
(
words
/
perWords
));
const
n
=
(
text
.
match
(
re
)
||
[]).
length
;
for
(
let
i
=
budget
;
i
<
n
;
i
++
)
{
hits
.
push
({
id
:
`budget
${
id
}
(>
${
budget
}
/
${
words
}
mots)`
,
w
:
weight
,
at
:
`occurrence
${
i
+
1
}
`
});
score
-=
weight
;
}
}
return
{
words
,
hits
,
score
:
Math
.
max
(
0
,
score
)
};
}
function
excerpt
(
text
,
index
)
{
return
'…'
+
text
.
slice
(
Math
.
max
(
0
,
index
-
38
),
index
+
52
).
replace
(
/
\s
+/g
,
' '
)
+
'…'
;
}
function
main
(
argv
)
{
const
json
=
argv
.
includes
(
'--json'
);
const
targets
=
argv
.
filter
((
a
)
=>
!
a
.
startsWith
(
'--'
));
...
...
lib/index.mjs
0 → 100644
View file @
417cea83
/** buvard package entry — the catalog, the budgets, and the lint core. */
export { CATALOG, CATALOG_VERSION, BUDGETS } from './catalog.mjs';
export { lint, bodyOf } from './lint.mjs';
lib/lint.mjs
0 → 100644
View file @
417cea83
/**
* buvard lint core — score a text against the catalog.
*
* Scoring starts at 100; each hit costs its weight (lexique 5, structure 8,
* servile 10); punctuation charges per occurrence past the budget: one tiret
* cadratin per 500 words, one exclamation per 1000. Every hit is a review
* candidate, not a verdict — the author's voice always wins.
*/
import { CATALOG, BUDGETS } from './catalog.mjs';
/** Body = everything after the frontmatter fence (frontmatter is data, not prose). */
export function bodyOf(text) {
const parts = text.split('---');
return parts.length >= 3 && text.startsWith('---') ? parts.slice(2).join('---').trim() : text.trim();
}
function excerpt(text, index) {
return '…' + text.slice(Math.max(0, index - 38), index + 52).replace(/\s+/g, ' ') + '…';
}
export function lint(text) {
const words = text.split(/\s+/).filter(Boolean).length;
const hits = [];
let score = 100;
for (const [id, w, , , re] of CATALOG) {
for (const m of text.matchAll(re)) {
hits.push({ id, w, at: excerpt(text, m.index) });
score -= w;
}
}
for (const { re, perWords, floor, id, weight } of BUDGETS) {
const budget = Math.max(floor, Math.floor(words / perWords));
const n = (text.match(re) || []).length;
for (let i = budget; i < n; i++) {
hits.push({ id: `budget ${id} (>${budget}/${words} mots)`, w: weight, at: `occurrence ${i + 1}` });
score -= weight;
}
}
return { words, hits, score: Math.max(0, score) };
}
package.json
View file @
417cea83
...
...
@@ -4,7 +4,7 @@
"description"
:
"buvard — l'anti-slop qui tache. Blotting paper for AI-flavored prose: a weighted multi-score linter for French and English slop patterns."
,
"type"
:
"module"
,
"bin"
:
{
"buvard"
:
"bin/buvard.js"
},
"main"
:
"lib/
catalog
.mjs"
,
"main"
:
"lib/
index
.mjs"
,
"files"
:
[
"bin"
,
"lib"
,
"docs"
,
"AGENTS.md"
,
"SKILL.md"
,
"README.md"
,
"LICENSE"
],
"scripts"
:
{
"test"
:
"node --test test/"
},
"keywords"
:
[
"slop"
,
"linter"
,
"prose"
,
"french"
,
"writing"
,
"ai-writing"
,
"style"
],
...
...
test/buvard.test.mjs
View file @
417cea83
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { lint, bodyOf } from '../
bin/buvard.
js';
import { lint, bodyOf } from '../
lib/index.m
js';
test('clean prose scores 100', () => {
const r = lint("J'ai réparé le montage smb. Le mot de passe vivait dans le trousseau.");
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment