okforest 0.2.2 → 0.4.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/dist/cli.mjs CHANGED
@@ -7,7 +7,7 @@ import { fileURLToPath } from "node:url";
7
7
  import { parseArgs, styleText } from "node:util";
8
8
  import { buildInventory } from "@okforest/okf";
9
9
  import { readTree } from "@okforest/okf/node";
10
- import { toReport, validate } from "@okforest/validate";
10
+ import { ruleUrl, toReport, validate } from "@okforest/validate";
11
11
  //#region src/io.ts
12
12
  /** Exit codes: 0 success, 1 validation errors, 2 usage or read problems. */
13
13
  const EXIT = {
@@ -269,9 +269,21 @@ function toText(result, io) {
269
269
  });
270
270
  out.push("");
271
271
  }
272
+ out.push(...ruleDocs(result.findings, io));
272
273
  out.push(summary(result, io));
273
274
  return `${out.join("\n")}\n`;
274
275
  }
276
+ /** Each rule that reported something, with its documentation page. */
277
+ function ruleDocs(findings, io) {
278
+ const ids = [...new Set(findings.map((f) => f.ruleId))];
279
+ if (ids.length === 0) return [];
280
+ const width = Math.max(...ids.map((id) => id.length));
281
+ return [
282
+ paint(io, "underline", "Rule docs"),
283
+ ...ids.map((id) => ` ${id.padEnd(width)} ${paint(io, "dim", ruleUrl(id))}`),
284
+ ""
285
+ ];
286
+ }
275
287
  function summary(result, io) {
276
288
  const plural = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
277
289
  const scope = `${plural(result.concepts, "concept")} in ${plural(result.files, "file")}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "okforest",
3
- "version": "0.2.2",
3
+ "version": "0.4.0",
4
4
  "description": "The OKForest CLI: validate Open Knowledge Format (OKF) v0.2 trees, inventory their metadata, and scaffold new trees from templates.",
5
5
  "keywords": [
6
6
  "okf",
@@ -32,15 +32,15 @@
32
32
  "node": ">=22"
33
33
  },
34
34
  "dependencies": {
35
- "@okforest/okf": "0.2.2",
36
- "@okforest/validate": "0.2.2"
35
+ "@okforest/okf": "0.4.0",
36
+ "@okforest/validate": "0.4.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@types/node": "^26.6.5",
40
- "@vitest/coverage-v8": "^5.0.3",
40
+ "@vitest/coverage-v8": "^5.0.4",
41
41
  "tsdown": "^0.23.0",
42
42
  "typescript": "^7.0.2",
43
- "vitest": "^5.0.3"
43
+ "vitest": "^5.0.4"
44
44
  },
45
45
  "scripts": {
46
46
  "build": "tsdown",
@@ -1,4 +1,6 @@
1
+ # yaml-language-server: $schema=https://www.okforest.ai/schemas/tree.schema.json
1
2
  # OKForest settings for this tree (an OKForest convention, not part of OKF).
3
+ # Every setting: https://www.okforest.ai/docs/tree-settings/
2
4
  tree: {{tree}}
3
5
  title: {{title_yaml}}
4
6
  owner: user:{{owner}} # exactly one person, accountable for the tree