@yegor256/dogent 0.7.8 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/package.json +1 -1
- package/src/args.js +13 -5
- package/src/dogent.js +20 -2
- package/src/rules/atomic.js +2 -1
- package/src/rules/index.js +2 -0
- package/src/rules/section-level.js +55 -0
- package/src/rules/simple.js +22 -2
- package/src/usage.js +1 -1
- package/src/version.js +16 -0
package/README.md
CHANGED
|
@@ -64,6 +64,7 @@ The command exits with a non-zero status when problems are found,
|
|
|
64
64
|
- Every line must be an instruction.
|
|
65
65
|
- Instructions must be grouped in sections.
|
|
66
66
|
- Section names must be short, 1-3 words.
|
|
67
|
+
- Every section must be a level-2 (`##`) heading, below the lone `#` title.
|
|
67
68
|
- Every line must be no longer than 80 symbols.
|
|
68
69
|
- The whole file must stay under 4000 tokens.
|
|
69
70
|
- Every line must sound like a command.
|
package/package.json
CHANGED
package/src/args.js
CHANGED
|
@@ -13,13 +13,15 @@ const minimist = require('minimist');
|
|
|
13
13
|
* The command-line arguments handed to dogent. It leans on minimist to split
|
|
14
14
|
* the raw argv into recognized options and the manifesto paths that remain.
|
|
15
15
|
* The `--sarif` flag switches the report to SARIF, while `--offline` forbids
|
|
16
|
-
* any talk to the LLM even when a token sits in the environment.
|
|
17
|
-
*
|
|
16
|
+
* any talk to the LLM even when a token sits in the environment. The `--help`
|
|
17
|
+
* flag, also spelled `-h`, asks for the usage banner. The `--version` flag
|
|
18
|
+
* asks for the release number. Everything after a `--` separator counts as a
|
|
19
|
+
* path, never as an option.
|
|
18
20
|
*/
|
|
19
21
|
class Args {
|
|
20
|
-
constructor(argv, flags = ['sarif', 'offline']) {
|
|
22
|
+
constructor(argv, flags = ['sarif', 'offline', 'help', 'version']) {
|
|
21
23
|
this.flags = flags;
|
|
22
|
-
this.parsed = minimist(argv, {boolean: flags, '--': true});
|
|
24
|
+
this.parsed = minimist(argv, {boolean: flags, alias: {help: 'h'}, '--': true});
|
|
23
25
|
}
|
|
24
26
|
sarif() {
|
|
25
27
|
return this.parsed.sarif === true;
|
|
@@ -27,12 +29,18 @@ class Args {
|
|
|
27
29
|
offline() {
|
|
28
30
|
return this.parsed.offline === true;
|
|
29
31
|
}
|
|
32
|
+
help() {
|
|
33
|
+
return this.parsed.help === true;
|
|
34
|
+
}
|
|
35
|
+
version() {
|
|
36
|
+
return this.parsed.version === true;
|
|
37
|
+
}
|
|
30
38
|
paths() {
|
|
31
39
|
return this.parsed._.concat(this.parsed['--']).map(String);
|
|
32
40
|
}
|
|
33
41
|
unknown() {
|
|
34
42
|
return Object.keys(this.parsed)
|
|
35
|
-
.filter((key) => key !== '_' && key !== '--' && !this.flags.includes(key))
|
|
43
|
+
.filter((key) => key !== '_' && key !== '--' && key !== 'h' && !this.flags.includes(key))
|
|
36
44
|
.map((key) => `${key.length === 1 ? '-' : '--'}${key}`);
|
|
37
45
|
}
|
|
38
46
|
}
|
package/src/dogent.js
CHANGED
|
@@ -14,19 +14,37 @@ const Sources = require('./sources');
|
|
|
14
14
|
const Openai = require('./openai');
|
|
15
15
|
const Oracle = require('./oracle');
|
|
16
16
|
const Usage = require('./usage');
|
|
17
|
+
const version = require('./version');
|
|
17
18
|
const rules = require('./rules');
|
|
18
19
|
|
|
19
20
|
const args = new Args(process.argv.slice(2));
|
|
20
21
|
const sarif = args.sarif();
|
|
22
|
+
const banner = 'Usage: dogent [--sarif] [--offline] <file.md|dir>...';
|
|
23
|
+
if (args.version()) {
|
|
24
|
+
process.stdout.write(`${version}\n`);
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
27
|
+
if (args.help()) {
|
|
28
|
+
process.stdout.write(
|
|
29
|
+
`${banner}\n\n` +
|
|
30
|
+
'Lint agentic manifesto files like SKILL.md and CLAUDE.md.\n\n' +
|
|
31
|
+
'Options:\n' +
|
|
32
|
+
' --sarif render the report as SARIF JSON\n' +
|
|
33
|
+
' --offline never call the LLM, even when a token exists\n' +
|
|
34
|
+
' --version show the version and exit\n' +
|
|
35
|
+
' --help show this help and exit\n'
|
|
36
|
+
);
|
|
37
|
+
process.exit(0);
|
|
38
|
+
}
|
|
21
39
|
const unknown = args.unknown();
|
|
22
40
|
if (unknown.length > 0) {
|
|
23
41
|
process.stderr.write(`Unknown option: ${unknown[0]}\n`);
|
|
24
|
-
process.stderr.write(
|
|
42
|
+
process.stderr.write(`${banner}\n`);
|
|
25
43
|
process.exit(2);
|
|
26
44
|
}
|
|
27
45
|
const paths = args.paths();
|
|
28
46
|
if (paths.length === 0) {
|
|
29
|
-
process.stderr.write(
|
|
47
|
+
process.stderr.write(`${banner}\n`);
|
|
30
48
|
process.exit(2);
|
|
31
49
|
}
|
|
32
50
|
const scanned = new Sources(paths).files();
|
package/src/rules/atomic.js
CHANGED
|
@@ -39,7 +39,8 @@ class Atomic {
|
|
|
39
39
|
}
|
|
40
40
|
judge(text, line, uri) {
|
|
41
41
|
const clean = text.replace(/^\s*(?:[-*+]|\d+\.)\s+/u, '').trimEnd();
|
|
42
|
-
|
|
42
|
+
const masked = clean.replace(/\b(?:e\.g|i\.e|etc)\./giu, (match) => match.replace(/\./gu, ' '));
|
|
43
|
+
if (!/[.!?]\s+\S/u.test(masked) && !/;/u.test(masked)) {
|
|
43
44
|
return [];
|
|
44
45
|
}
|
|
45
46
|
return [new Violation(
|
package/src/rules/index.js
CHANGED
|
@@ -28,11 +28,13 @@ const Passive = require('./passive');
|
|
|
28
28
|
const Unique = require('./unique');
|
|
29
29
|
const Consistent = require('./consistent');
|
|
30
30
|
const Simple = require('./simple');
|
|
31
|
+
const SectionLevel = require('./section-level');
|
|
31
32
|
|
|
32
33
|
module.exports = () => [
|
|
33
34
|
new Grouped(),
|
|
34
35
|
new Empty(),
|
|
35
36
|
new ShortSections(),
|
|
37
|
+
new SectionLevel(),
|
|
36
38
|
new LineLength(80),
|
|
37
39
|
new TokenCount(4000),
|
|
38
40
|
new NoArticles(),
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SPDX-FileCopyrightText: Copyright (c) 2026 Yegor Bugayenko
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
const Violation = require('../violation');
|
|
9
|
+
const Region = require('../region');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* SectionLevel.
|
|
13
|
+
*
|
|
14
|
+
* Demands that every section sit at the second level, marked by two
|
|
15
|
+
* hashes. A lone top-level title may open the file, but any later
|
|
16
|
+
* first-level heading or any deeper sub-heading breaks the flat shape
|
|
17
|
+
* a manifesto must keep.
|
|
18
|
+
*
|
|
19
|
+
* The check is standalone and deterministic, so prompt() returns an
|
|
20
|
+
* empty string and the AI oracle never re-checks this rule.
|
|
21
|
+
*/
|
|
22
|
+
class SectionLevel {
|
|
23
|
+
constructor() {
|
|
24
|
+
this.id = 'section-level';
|
|
25
|
+
}
|
|
26
|
+
prompt() {
|
|
27
|
+
return '';
|
|
28
|
+
}
|
|
29
|
+
violations(document) {
|
|
30
|
+
const uri = document.uri();
|
|
31
|
+
return document
|
|
32
|
+
.walk({
|
|
33
|
+
header: (text, line, depth) => [{line, depth}],
|
|
34
|
+
prose: () => [],
|
|
35
|
+
snippet: () => [],
|
|
36
|
+
bullets: () => [],
|
|
37
|
+
frontmatter: () => []
|
|
38
|
+
})
|
|
39
|
+
.map((header, index) => this.leveled(header, index, uri))
|
|
40
|
+
.flat();
|
|
41
|
+
}
|
|
42
|
+
leveled(header, index, uri) {
|
|
43
|
+
if (header.depth === 2 || header.depth === 1 && index === 0) {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
return [new Violation(
|
|
47
|
+
this.id,
|
|
48
|
+
'error',
|
|
49
|
+
`section must be a level-2 heading, found ${header.depth}`,
|
|
50
|
+
new Region(uri, header.line, 1)
|
|
51
|
+
)];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = SectionLevel;
|
package/src/rules/simple.js
CHANGED
|
@@ -8,12 +8,31 @@
|
|
|
8
8
|
const Violation = require('../violation');
|
|
9
9
|
const Region = require('../region');
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Counts the commas that sit inside a coordinated `A, B, or C` list run,
|
|
13
|
+
* so an enumeration can be discounted before clause commas are weighed.
|
|
14
|
+
* @param {string} text The line to scan
|
|
15
|
+
* @return {number} The number of commas belonging to coordinated lists
|
|
16
|
+
*/
|
|
17
|
+
const listCommas = function listCommas(text) {
|
|
18
|
+
const runs = text.match(/(?:[^,]+,\s*)+(?:or|and)\b/giu);
|
|
19
|
+
if (runs === null) {
|
|
20
|
+
return 0;
|
|
21
|
+
}
|
|
22
|
+
return runs.reduce((sum, run) => {
|
|
23
|
+
const inner = run.match(/,/gu);
|
|
24
|
+
return sum + (inner === null ? 0 : inner.length);
|
|
25
|
+
}, 0);
|
|
26
|
+
};
|
|
27
|
+
|
|
11
28
|
/**
|
|
12
29
|
* Simple.
|
|
13
30
|
*
|
|
14
31
|
* Demands simple grammar over ambiguity. A standalone checker can only
|
|
15
32
|
* guess: it counts commas and conjunctions to flag lines that pile up
|
|
16
|
-
* clauses.
|
|
33
|
+
* clauses. Commas inside a coordinated `A, B, or C` list are discounted
|
|
34
|
+
* first, so a lone enumeration sitting in one clause does not read as
|
|
35
|
+
* tangled. Its prompt hands the subtler tangle judgement to the oracle,
|
|
17
36
|
* which weighs true clause depth rather than counting punctuation.
|
|
18
37
|
*/
|
|
19
38
|
class Simple {
|
|
@@ -36,8 +55,9 @@ class Simple {
|
|
|
36
55
|
judge(text, line, uri) {
|
|
37
56
|
const commas = text.match(/,/gu);
|
|
38
57
|
const commaCount = commas === null ? 0 : commas.length;
|
|
58
|
+
const clauseCommas = commaCount - listCommas(text);
|
|
39
59
|
const hasConjunction = /\b(?:if|when|unless|because|although|while)\b/iu.test(text);
|
|
40
|
-
const tangled = hasConjunction &&
|
|
60
|
+
const tangled = hasConjunction && clauseCommas >= 2;
|
|
41
61
|
if (!tangled) {
|
|
42
62
|
return [];
|
|
43
63
|
}
|
package/src/usage.js
CHANGED
|
@@ -45,7 +45,7 @@ class Usage {
|
|
|
45
45
|
return this.sent / 1e6 * price.input + this.received / 1e6 * price.output;
|
|
46
46
|
}
|
|
47
47
|
text() {
|
|
48
|
-
return `OpenAI: ${this.model}, ${this.sent}
|
|
48
|
+
return `OpenAI: ${this.model}, ${this.sent}+${this.received} tokens, ${(this.cost() * 100).toFixed(2)}¢`;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
package/src/version.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* SPDX-FileCopyrightText: Copyright (c) 2026 Yegor Bugayenko
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Version.
|
|
10
|
+
*
|
|
11
|
+
* The current release of dogent, replaced on every release by rultor.
|
|
12
|
+
* The default `0.9.0` marks an unreleased build straight from source.
|
|
13
|
+
*/
|
|
14
|
+
const version = '0.9.0';
|
|
15
|
+
|
|
16
|
+
module.exports = version;
|