@yegor256/dogent 0.7.7 → 0.8.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/package.json +1 -1
- package/src/args.js +13 -5
- package/src/dogent.js +20 -2
- package/src/rules/atomic.js +10 -11
- package/src/rules/simple.js +22 -2
- package/src/usage.js +1 -1
- package/src/version.js +16 -0
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
|
@@ -12,18 +12,20 @@ const Region = require('../region');
|
|
|
12
12
|
* Atomic.
|
|
13
13
|
*
|
|
14
14
|
* Demands that every line carry exactly one instruction. A standalone
|
|
15
|
-
* checker only
|
|
16
|
-
* mid-line with more text after it, or two
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
15
|
+
* checker spots only the unambiguous signs: a sentence terminator
|
|
16
|
+
* sitting mid-line with more text after it, or two clauses welded
|
|
17
|
+
* together by a semicolon. An " and " or " then " is left alone, since
|
|
18
|
+
* no suffix heuristic can tell a second verb from a coordinated object
|
|
19
|
+
* or temporal adverb without reading the word as language. The prompt
|
|
20
|
+
* hands that subtler clause-counting to the AI oracle, which weighs the
|
|
21
|
+
* full sentence before judging a line as multi-instruction.
|
|
20
22
|
*/
|
|
21
23
|
class Atomic {
|
|
22
24
|
constructor() {
|
|
23
25
|
this.id = 'atomic';
|
|
24
26
|
}
|
|
25
27
|
prompt() {
|
|
26
|
-
return `${this.id}: flag any line that carries more than one instruction, counting distinct clauses
|
|
28
|
+
return `${this.id}: flag any line that carries more than one instruction, counting distinct clauses whether or not a semicolon, "and", or "then" welds them, yet never count a coordinated object or noun phrase trailing "and" or "then" as a second instruction`;
|
|
27
29
|
}
|
|
28
30
|
violations(document) {
|
|
29
31
|
const uri = document.uri();
|
|
@@ -37,11 +39,8 @@ class Atomic {
|
|
|
37
39
|
}
|
|
38
40
|
judge(text, line, uri) {
|
|
39
41
|
const clean = text.replace(/^\s*(?:[-*+]|\d+\.)\s+/u, '').trimEnd();
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
!/^(?:the|a|an)$/u.test(weld.groups.verb) &&
|
|
43
|
-
!/(?:ly|al|ial|ous|ive|less|ic|ary|ory|able|ible|ate)$/u.test(weld.groups.verb);
|
|
44
|
-
if (!/[.!?]\s+\S/u.test(clean) && !/;/u.test(clean) && !welded) {
|
|
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)) {
|
|
45
44
|
return [];
|
|
46
45
|
}
|
|
47
46
|
return [new Violation(
|
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.8.0` marks an unreleased build straight from source.
|
|
13
|
+
*/
|
|
14
|
+
const version = '0.8.0';
|
|
15
|
+
|
|
16
|
+
module.exports = version;
|