@yegor256/dogent 0.2.0 → 0.3.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 CHANGED
@@ -32,6 +32,13 @@ Lint several files at once:
32
32
  npx @yegor256/dogent SKILL.md CLAUDE.md AGENTS.md
33
33
  ```
34
34
 
35
+ Point it at a directory to lint the default manifestos it holds
36
+ (`AGENTS.md`, `CLAUDE.md`, `SKILL.md`, `SKILLS.md`):
37
+
38
+ ```bash
39
+ npx @yegor256/dogent .
40
+ ```
41
+
35
42
  Sample output:
36
43
 
37
44
  ```text
package/package.json CHANGED
@@ -40,5 +40,5 @@
40
40
  "lint": "eslint .",
41
41
  "test": "mocha 'test/**/*.js' --timeout 60000"
42
42
  },
43
- "version": "0.2.0"
43
+ "version": "0.3.0"
44
44
  }
package/src/dogent.js CHANGED
@@ -9,17 +9,18 @@
9
9
  const fs = require('fs');
10
10
  const Markdown = require('./markdown');
11
11
  const Report = require('./report');
12
+ const Sources = require('./sources');
12
13
  const rules = require('./rules');
13
14
 
14
15
  const argv = process.argv.slice(2);
15
16
  const sarif = argv.indexOf('--sarif') !== -1;
16
- const files = argv.filter((arg) => arg !== '--sarif');
17
- if (files.length === 0) {
18
- process.stderr.write('Usage: dogent [--sarif] <file.md>...\n');
17
+ const paths = argv.filter((arg) => arg !== '--sarif');
18
+ if (paths.length === 0) {
19
+ process.stderr.write('Usage: dogent [--sarif] <file.md|dir>...\n');
19
20
  process.exit(2);
20
21
  }
21
22
  const found = [];
22
- files.forEach((file) => {
23
+ new Sources(paths).files().forEach((file) => {
23
24
  const document = new Markdown(file, fs.readFileSync(file, 'utf8')).document();
24
25
  rules().forEach((rule) => {
25
26
  rule.violations(document).forEach((violation) => found.push(violation));
package/src/sources.js ADDED
@@ -0,0 +1,42 @@
1
+ /*
2
+ * SPDX-FileCopyrightText: Copyright (c) 2026 Yegor Bugayenko
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ 'use strict';
7
+
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+
11
+ /**
12
+ * Sources.
13
+ *
14
+ * The paths passed on the command line. Each path names either one
15
+ * manifesto file or one directory. A directory expands into the default
16
+ * manifesto files it actually contains, so `dogent .` lints every known
17
+ * manifesto in the current folder.
18
+ */
19
+ class Sources {
20
+ constructor(paths, defaults = ['AGENTS.md', 'CLAUDE.md', 'SKILL.md', 'SKILLS.md']) {
21
+ this.paths = paths;
22
+ this.defaults = defaults;
23
+ }
24
+ files() {
25
+ const found = [];
26
+ this.paths.forEach((entry) => {
27
+ if (fs.statSync(entry).isDirectory()) {
28
+ this.defaults.forEach((name) => {
29
+ const file = path.join(entry, name);
30
+ if (fs.existsSync(file)) {
31
+ found.push(file);
32
+ }
33
+ });
34
+ } else {
35
+ found.push(entry);
36
+ }
37
+ });
38
+ return found;
39
+ }
40
+ }
41
+
42
+ module.exports = Sources;